BayesicFitting

Model Fitting and Evidence Calculation

View project on GitHub



class IterativeFitter( BaseFitter )Source

Base class with methods common to all iterative fitters.

Author: Do Kester.

Attributes

  • tolerance : float
         When absolute and relative steps in subsequent chisq steps are less than
         tolerance, the fitter stops. Default = 0.0001

  • maxIter : int
         When the number of iterations gets larger than maxiter the fitter
         stops with a ConvergenceError Default = 1000 * nparams

  • iter : int (read only)
         iteration counter

  • ntrans : int (read only)
         number of transforms

  • verbose : int
         information per iteration.
         0 : silent
         1 : base information (default)
         2 : report about every 100th iteration
         3 : report about every ietration

  • tooLarge : int
         When the length parameter array is too large to make a Hessian.
         To avert OutOfMemory. Default = 100

  • plotter : Plotter
         Iteration plotter class. Default = IterationPlotter

  • plotIter : int
         Produce a plot for every plotIter-th iteration.
         Default = 0 (no plotting)

Raises

ConvergenceError Something went wrong during the convergence if the fit.

IterativeFitter( xdata, model, maxIter=None, tolerance=0.0001, verbose=1, **kwargs )

Create a new iterative fitter, providing xdatas and model.

This is a base class. It collects stuff common to all iterative fitters. It does not work by itself.

Parameters

  • xdata : array_like
         array of independent input values

  • model : Model
         the model function to be fitted

  • tolerance : float
         When absolute and relative steps in subsequent chisq steps are less than
         tolerance, the fitter stops. Default = 0.01

  • maxIter : None or int
         When the number of iterations gets larger than maxiter the fitter
         stops with a ConvergenceError Default = 1000 * nparams

  • verbose : int
         0 : silent
         1 : report result
         2 : report every 100th iteration
         3 : report every iteration kwargs for BaseFitter
         map, keep, fixedScale

setParameters( params )
Initialize the parameters of the model A little superfluous: see [link](./link.md) Model#setParameters

Parameters

  • params : array_like
         initial parameters

doPlot( param, force=False )
Plot intermediate result.

Parameters

  • param : array_like
         of the model
  • force : bool
         do the plot

fitprolog( ydata, weights=None, accuracy=None, keep=None )
Prolog for all iterative Fitters.
  1. Sets up plotting (if requested)
  2. Sets self.iter and self.ntrans to 0
  3. Checks data/weighs for Nans
  4. Makes fitIndex.

Parameters

  • ydata : array_like
         the data vector to be fitted
  • weights : array_like
         weights pertaining to the data
  • accuracy : float or array_like
         accuracy of (individual) data
  • keep : dict of {int:float}
         dictionary of indices (int) to be kept at a fixed value (float)

Returns

  • fitIndex : ndarray of int
         Indices of the parameters that need fitting

fit( ydata, weights=None, keep=None, **kwargs )
Return model parameters fitted to the data.

It will calculate the hessian matrix and chisq.

Parameters

  • ydata : array_like
         the data vector to be fitted
  • weights : array_like
         weights pertaining to the data
  • keep : dict of {int:float}
         dictionary of indices (int) to be kept at a fixed value (float)
  • kwargs :
         passed to the fitter

Raises

ConvergenceError if it stops when the tolerance has not yet been reached.

report( verbose, param, chi, more=None, force=False )
Report on intermediate results.
Methods inherited from BaseFitter