BayesicFitting

Model Fitting and Evidence Calculation

View project on GitHub



class GaussPrior( Prior )Source

Gauss prior distribution. Use normalized version

  Pr( x ) = 1 / √( 2 π s2 ) exp( - 0.5 * ( ( x - c ) / s )2 )

  By default:
     c = center = 0
     s = scale = 1.

By default the domain is [-Inf,+Inf]. In computational practice the domain is limited to about [-8.5, 8.5] scale units. Outside that range the Gaussian is indistinguishable from 0, computationally.

It can also have a limited domain.

According to integral-calculator.com we have

domain2unit:
     u = 0.5 * ( erf( ( d - c ) / ( s * √2 ) ) + 1 ) unit2domain:
     d = erfinv( 2 * u - 1 ) * s * √2 + c

Examples

pr = GaussPrior()                         # center=0, scale=1
pr = GaussPrior( center=1.0, scale=0.5 )
pr = GaussPrior( limits=[0,None] )        # limited to values >= 0
pr = GaussPrior( center=1, circular=3 )   # circular between 0.5 and 2.5

Attributes

  • center : float
         center of the Gaussian prior
  • scale : float
         scale of the Gaussian prior

Attributes from Prior

lowLimit, highLimit, circular, deltaP, _lowDomain, _highDomain

GaussPrior( center=0.0, scale=1.0, limits=None, circular=False, prior=None )

Constructor.

Parameters

  • center : float
         of the location of the prior
  • scale : float
         of the exponential
  • limits : None or [float,float]
         None no limits are set
         2 floats lowlimit and highlimit
  • circular : bool or float
         bool : y|n circular with period from limits[0] to limits[1]
         float : period of circularity
  • prior : GaussPrior
         prior to copy (with new scale if applicable)

copy( )

Copy the prior

domain2Unit( dval )
Return a value in [0,1] given a value within the valid domain of a parameter for a Gauss distribution.

  u = 0.5 * ( erf( ( d - center ) / ( √2 * scale ( ) + 1 )

Parameters

  • dval : float or array_like
         value(s) within the domain of a parameter

unit2Domain( uval )
Return a value within the valid domain of the parameter given a value between [0,1] for a Gauss distribution.

  d = erfinv( 2 * u - 1 ) * scale * √2 + center

Parameters

  • uval : float or array_like
         value(s) within [0,1]

result( x )
Return a the result of the distribution function at x.

Parameters

  • x : float or array_like
         value within the domain of a parameter

logResult( x )
Return a the log of the result of the prior.

Parameters

  • x : float
         value within the domain of a parameter

partialLog( x )
Return partial derivative of log( Prior ) wrt x.

Parameters

  • x : float
         the value

isBound( )

Return true if the integral over the prior is bound.

shortName( )

Return a string representation of the prior.

Methods inherited from Prior