Skip to main content
`Ctrl`+`K`

# SimplexLSQFitter

class astropy.modeling.fitting.SimplexLSQFitter

  Bases: `Fitter`

  Simplex algorithm and least squares statistic.

  Raises:
    `ModelLinearityError`

      A linear model is passed to a nonlinear fitter

  Attributes Summary

  `supported_constraints` |

  Methods Summary

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

  Attributes Documentation

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

  Methods Documentation

  __call__(model, x, y, z=None, weights=None, *, inplace=False, **kwargs)

    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.

      kwargs `python:dict`

        optional keyword arguments to be passed to the optimizer or the statistic

      maxiter `python:int`

        maximum number of iterations

      acc `python:float`

        Relative error in approximate solution

      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.

      inplace bool, optional

        If `False` (the default), a copy of the model with the fitted parameters set will be returned. If `True`, the returned model will be the same instance as the model passed in, and the parameter values will be changed inplace.

    Returns:
      fitted_model `FittableModel`

        If `inplace` is `False` (the default), this is a copy of the input model with parameters set by the fitter. If `inplace` is `True`, this is the same model as the input model, with parameters updated to be those set by the fitter.

  objective_function(fps, *args)

    Function to minimize.

    Parameters:
      fps `python:list`

        parameters returned by the fitter

      args `python:list`

        [model, [other_args], [input coordinates]] other_args may include weights or any other quantities specific for a statistic

    Notes

    The list of arguments (args) is set in the `__call__` method. Fitters may overwrite this method, e.g. when statistic functions require other arguments.