BayesicFitting

Model Fitting and Evidence Calculation

View project on GitHub



class CurveFitter( IterativeFitter )Source

CurveFitter implements scipy.optimize.curvefit.

Author: Do Kester.

Attributes

  • method : {'lm', 'trf', 'dogbox'}
         'lm' LevenbergMarquardt (default for no limits)
         'trf' Trust Region Reflective (default for limits)
         'dogbox' for small problems with limits

Raises

ConvergenceError Something went wrong during the convergence if the fit.

CurveFitter( xdata, model, method=None, fixedScale=None, map=False, keep=None )

Create a new class, providing inputs and model.

Parameters

  • xdata : array_like
         array of independent input values
  • model : Model
         the model function to be fitted
  • method : 'lm' | 'trf' | 'dogbox'
         method to be used
  • fixedScale : None or float
         the fixed noise scale.
  • map : bool (False)
         When true, the xdata should be interpreted as a map.
         The fitting is done on the pixel indices of the map,
         using ImageAssistant
  • keep : dict of {int:float}
         dictionary of indices (int) to be kept at a fixed value (float)
         The values of keep will be used by the Fitter as long as the Fitter exists.
         See also fit( ..., keep=dict )

fit( ydata, weights=None, inipar=None, keep=None, limits=None, accuracy=None, plot=False, **kwargs )
Return parameters for the model fitted to the data array.

Parameters

  • ydata : array_like
         the data vector to be fitted
  • weights : array_like
         weights pertaining to the data
         The weights are relative weights unless fixedScale is set.
  • accuracy : float or array_like
         accuracy of (individual) data
  • inipar : array_like
         inital parameters (default from Model)
  • keep : dict of {int:float}
         dictionary of indices (int) to be kept at a fixed value (float)
         The values of keep are only valid for this fit
         See also CurveFitter( ..., keep=dict )
  • limits : None or list of 2 floats or list of 2 array_like
         None : from Model if Model has limits set else no limits
         [-inf,+inf] : no limits applied
         [lo,hi] : low and high limits for all values
         [la,ha] : low array and high array limits for the values
  • plot : bool
         Plot the results.
  • kwargs : dict
         keywords arguments to be passed to :ref:curve_fit<scipy.optimize.curve_fit>

Raises

ValueError when ydata or weights contain a NaN

result( xdata, *fitpar )
Result method to make connection to the scipy optimizers

Parameters

  • xdata : array_like
         input data
  • fitpar : tuple of float
         parameters for the model

jacobian( xdata, *fitpar )
Method to make connection to the scipy optimizers

Parameters

  • xdata : array_like
         input data
  • fitpar : (tuple of) float
         parameters for the model
Methods inherited from IterativeFitter
Methods inherited from BaseFitter