astro py:docs

- Index
- Modules

### Navigation

- next »
- « previous |
- Astropy v5.2.1 »
- Models and Fitting (`astropy.modeling`) »
- Reference/API »
- LMLSQFitter

# LMLSQFitter

class astropy.modeling.fitting.LMLSQFitter(calc_uncertainties=False)

  Bases: `_NLLSQFitter`

  `scipy.optimize.least_squares` Levenberg-Marquardt algorithm and least squares statistic.

  Parameters:
    calc_uncertainties bool

      If the covarience matrix should be computed and set in the fit_info. Default: False

  Attributes:
    fit_info

      A `scipy.optimize.OptimizeResult` class which contains all of the most recent fit information

  Attributes Summary

  `supported_constraints` | The constraint types supported by this fitter type.

  Methods Summary

  `__call__`(model, x, y[, z, weights, maxiter, ...]) | Fit data to this model.
  `objective_function`(fps, *args) | Function to minimize.

  Attributes Documentation

  supported_constraints = ['fixed', 'tied', 'bounds']

    The constraint types supported by this fitter type.

  Methods Documentation

  __call__(model, x, y, z=None, weights=None, maxiter=100, acc=1e-07, epsilon=1.4901161193847656e-08, estimate_jacobian=False, filter_non_finite=False)

    Fit data to this model.

    Parameters:
      model `FittableModel`

        model to fit to x, y, z

      x `array`

        input coordinates

      y `array`

        input coordinates

      z `array`, optional

        input coordinates

      weights `array`, optional

        Weights for fitting. For data with Gaussian uncertainties, the weights should be 1/sigma.

      maxiter `python:int`

        maximum number of iterations

      acc `python:float`

        Relative error desired in the approximate solution

      epsilon `python:float`

        A suitable step length for the forward-difference approximation of the Jacobian (if model.fjac=None). If epsfcn is less than the machine precision, it is assumed that the relative errors in the functions are of the order of the machine precision.

      estimate_jacobian bool

        If False (default) and if the model has a fit_deriv method, it will be used. Otherwise the Jacobian will be estimated. If True, the Jacobian will be estimated in any case.

      equivalencies `python:list` or `python:None`, optional, keyword-only

        List of additional equivalencies that are should be applied in case x, y and/or z have units. Default is None.

      filter_non_finite bool, optional

        Whether or not to filter data with non-finite values. Default is False

    Returns:
      model_copy `FittableModel`

        a copy of the input model with parameters set by the fitter

  objective_function(fps, *args)

    Function to minimize.

    Parameters:
      fps `python:list`

        parameters returned by the fitter

      args `python:list`

        [model, [weights], [input coordinates]]