LevMarLSQFitter¶

class
astropy.modeling.fitting.
LevMarLSQFitter
[source]¶ Bases:
object
LevenbergMarquardt algorithm and least squares statistic.
Notes
The
fit_info
dictionary contains the values returned byscipy.optimize.leastsq
for the most recent fit, including the values from theinfodict
dictionary it returns. See thescipy.optimize.leastsq
documentation for details on the meaning of these values. Note that thex
return value is not included (as it is instead the parameter values of the returned model).Additionally, one additional element of
fit_info
is computed whenever a model is fit, with the key ‘param_cov’. The corresponding value is the covariance matrix of the parameters as a 2D numpy array. The order of the matrix elements matches the order of the parameters in the fitted model (i.e., the same order asmodel.param_names
). Attributes
 fit_infodict
The
scipy.optimize.leastsq
result for the most recent fit (see notes).
Attributes Summary
The constraint types supported by this fitter type.
Methods Summary
__call__
(self, model, x, y[, z, weights, …])Fit data to this model.
objective_function
(self, fps, \*args)Function to minimize.
Attributes Documentation

supported_constraints
= ['fixed', 'tied', 'bounds']¶ The constraint types supported by this fitter type.
Methods Documentation

__call__
(self, model, x, y, z=None, weights=None, maxiter=100, acc=1e07, epsilon=1.4901161193847656e08, estimate_jacobian=False)[source]¶ Fit data to this model.
 Parameters
 model
FittableModel
model to fit to x, y, z
 xarray
input coordinates
 yarray
input coordinates
 zarray (optional)
input coordinates
 weightsarray (optional)
Weights for fitting. For data with Gaussian uncertainties, the weights should be 1/sigma.
 maxiterint
maximum number of iterations
 accfloat
Relative error desired in the approximate solution
 epsilonfloat
A suitable step length for the forwarddifference 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_jacobianbool
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.
 equivalencieslist or None, optional and keywordonly argument
List of additional equivalencies that are should be applied in case x, y and/or z have units. Default is None.
 model
 Returns
 model_copy
FittableModel
a copy of the input model with parameters set by the fitter
 model_copy