BayesicFitting

Model Fitting and Evidence Calculation

View project on GitHub



class ModelDistribution( ScaledErrorDistribution )Source

To calculate the probability of a model M from a set of models S, given some data D, use Bayes rule

     P( M|DS ) = P( M|S ) * P( D|MS ) / P( D|S )
     posterior = prior * likelihood / evidence

This class calculates the likelihood P( D|MS ). On another level where we calculate the probability of the parameters p, we see this likelhood appear as evidence P( D|M ).

Again using Bayes

     P( p|DM ) = P( p|M ) * P( D|pM ) / P( D|M )

The evidence here is calculated as the integral over a Gausian approximation of the posterior.

Author Do Kester.

ModelDistribution( arbiter=None, scale=1.0, limits=None, copy=None, **kwargs )

Default Constructor.

Parameters

  • arbiter : None or BaseFitter or str
         to provide the evidence
         None select fitter automatically
         BaseFiter Use this fitter
         str "fitter", "levenberg", "curve", "amoeba", "NestedSampler"

  • scale : float
         noise scale

  • limits : None or list of 2 floats [low,high]
         None : no limits implying fixed scale
         low low limit on scale (needs to be >0)
         high high limit on scale
         when limits are set, the scale is not fixed.

  • copy : ModelDistribution
         distribution to be copied.

  • kwargs : dict
         to be applied to arbiter

copy( )

Return copy of this.

acceptWeight( )
True if the distribution accepts weights. Always true for this distribution.

logLikelihood_alt( problem, allpars )
Return the log( likelihood ) for a Gaussian distribution.

Alternate calculation

Parameters

  • problem : Problem
         to be solved
  • allpars : array_like
         list of all parameters in the problem
         Return optimal parameters of the fit

logLdata( problem, allpars, mockdata=None )
Return the log( likelihood ) for each residual
    logL = sum( logLdata )

Parameters

  • problem : Problem
         to be solved
  • allpars : array_like
         list of all parameters in the problem
  • mockdata : array_like
         as calculated by the model
Methods inherited from ScaledErrorDistribution
Methods inherited from ErrorDistribution