class LaplaceErrorDistribution( ScaledErrorDistribution ) | Source |
---|
To calculate a Laplace likelihood.
For one residual, x, it holds
f( x ) = 1 / ( 2 s ) exp( - |x| / s )
where s is the scale. s is a hyperparameter, which might be estimated from the data.
The variance of this function is σ2 = 2 s2. See: toSigma()
The function is mostly used to calculate the likelihood L over N residuals, or easier using log likelihood, logL.
logL = log( N / ( 2 s ) ) - ∑( |x| / s )
Using weights this becomes
logL = log( ∑( w ) / ( 2 s ) ) - ∑( w |x| / s )
Using this error distribution results in median-like solutions.
Author Do Kester.
LaplaceErrorDistribution( scale=1.0, limits=None, copy=None ) |
---|
Constructor of Laplace Distribution.
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 : LaplaceErrorDistribution
distribution to be copied.
copy( ) |
---|
acceptWeight( ) |
---|
toSigma( scale ) |
---|
- scale : float
the scale of this Laplace distribution.
getScale( problem, allpars=None ) |
---|
Parameters
- problem : Problem
to be solved - allpars : array_like
None take parameters from problem.model
list of all parameters in the problem
getSumRes( problem, allpars=None, scale=1 ) |
---|
sum ( | res | )
Parameters
- problem : Problem
to be solved - allpars : array_like
None take parameters from problem.model
list of all parameters in the problem - scale : float or array_like
scale of residuals (from accuracies or noisescale of errdis)
logLikelihood_alt( problem, allpars ) |
---|
Parameters
- problem : Problem
to be solved - allpars : array_like
parameters of the problem
logLdata( problem, allpars, mockdata=None ) |
---|
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 ) |
---|
dL/ds is not implemented for problems with accuracy
Parameters
- problem : Problem
to be solved - allpars : array_like
list of all parameters in the problem - fitIndex : array_like
indices of parameters to be fitted
nextPartialData( problem, allpars, fitIndex, mockdata=None ) |
---|
dL/ds is not implemented for problems with accuracy
Parameters
- problem : Problem
to be solved - allpars : array_like
list of all parameters in 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 |
---|
- getGaussianScale( problem, allpars=None )
- getResiduals( problem, allpars=None )
- getChisq( problem, allpars=None )
- isBound( )
- keepFixed( fixed=None )
- setPriors( priors )
- domain2Unit( dval, ks )
- unit2Domain( uval, ks )
- logCLhood( problem, allpars )
- logLhood( problem, allpars )
- partialLogL( problem, allpars, fitIndex )
- numPartialLogL( problem, allpars, fitIndex )
- updateLogL( problem, allpars, parval=None )
- setResult( )
- hyparname( k )