satlas.stats.fitting.chisquare_model

satlas.stats.fitting.chisquare_model(params, f, x, y, yerr, xerr=None, func=None)[source]

Model function for chisquare fitting routines as established in this module.

Parameters:
  • params (lmfit.Parameters) – Instance of lmfit.Parameters object, to be assigned to the model object.
  • f (BaseModel) – Callable instance with the correct methods for the fitmethods.
  • x (array_like) – Experimental data for the x-axis.
  • y (array_like) – Experimental data for the y-axis.
  • yerr (array_like) – Experimental errorbars on the y-axis.
Other Parameters:
 
  • xerr (array_like, optional) – Given an array with the same size as x, the error is taken into account by using the method of estimated variance. Defaults to None.
  • func (function, optional) – Given a function, the errorbars on the y-axis is calculated from the fitvalue using this function. Defaults to None.
Returns:

Array containing the residuals for the given parameters, divided by the uncertainty.

Return type:

NumPy array

Note

If a custom function is to be used for the calculation of the residual, this function should be overwritten.

The method of estimated variance calculates the chisquare in the following way:

\sqrt{\chi^2} = \frac{y-f(x)}{\sqrt{\sigma_x^2+f'(x)^2\sigma_x^2}}