BayesicFitting

Model Fitting and Evidence Calculation

View project on GitHub



class CauchyErrorDistribution( ScaledErrorDistribution )Source

To calculate a Cauchy or Lorentz likelihood.

f( x ) = s / ( π * ( s2 + x2 ) )

where x = residual and s = scale

The function is mostly used to calculate the likelihood L, or easier to use log likelihood, logL.

  logL = N ( log( s ) - log( π ) ) - ∑( log( x2 + s2 ) )

Weights are not possible in this error distribution. They are silently ignored.

s is a hyperparameter, which might be estimated from the data.

Author Do Kester.

CauchyErrorDistribution( scale=1.0, limits=None, copy=None )

Constructor.

Parameters

  • 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 : CauchyErrorDistribution
         distribution to be copied.

copy( )

Return copy of this.

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

getScale( problem, allpars=None )
Return the noise scale as calculated from the residuals.

Parameters

  • problem : Problem
         to be solved
  • allpars : array_like
         None take parameters from problem.model
         list of all parameters in the problem

funct( scale )
Internal use, only.

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

Cauchy distr : f( x ) = s / ( π * ( s2 + x2 ) )

where x = residual and s = scale

Alternate calculation

Parameters

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

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

partialLogL_alt( problem, allpars, fitIndex )
Return the partial derivative of log( likelihood ) to the parameters in fitIndex.

Alternate calculation

dL/ds is not implemented for problems with accuracy

Parameters

  • problem : Problem
         to be solved
  • allpars : array_like
         parameters of the problem
  • fitIndex : array_like
         indices of parameters to be fitted

nextPartialData( problem, allpars, fitIndex, mockdata=None )
Return the partial derivative of log( likelihood ) to the parameters in fitIndex.

dL/ds is not implemented for problems with accuracy

Parameters

  • problem : Problem
         to be solved
  • allpars : array_like
         parameters of the problem
  • fitIndex : array_like
         indices of parameters to be fitted
  • mockdata : array_like
         as calculated by the model
Methods inherited from ScaledErrorDistribution
Methods inherited from ErrorDistribution