class ErrorDistribution( object ) | Source |
---|
ErrorDistribution defines general methods for a error distribution.
Error distributions are used to calculate the likelihoods.
Author Do Kester.
Attributes
- hyperpar : HyperParameter
hyperparameter for the error distribution - deltaP : float
delta for calculating numerical derivatives - ncalls : int
number of calls to the logLikelihood - nparts : int
number of calls to the partial of the logLikelihood - sumweight : float
sum over the weights or ndata - ndata : int
number of points in data - hypar : [float]
list of values for the hyperparameters - nphypar : int
number of hyper parameters in this error distribution - constrain : None or callable
None: Use logLikelihood as is
callable: logL = func( logL, problem, allpars, lowLhood )
returning a (modified) value of the logLikelihood.
ErrorDistribution( fixed=None, constrain=None, copy=None ) |
---|
Constructor.
Parameters
- fixed : dictionary of {int:float}
int list if parameters to fix permanently. Default None.
float list of values for the fixed parameters. - constrain : None or callable
function as: func( logL, problem, allpars )
returning a (modified) value of the logLikelihood. - copy : ErrorDistribution
distribution to be copied.
Raise
ValueError when constrain is not a callable method.
copy( ) |
---|
getGaussianScale( problem, allpars=None ) |
---|
*** Gaussian approximation ***
Parameters
- problem : Problem
to be solved - allpars : array_like
None take parameters from problem.model
list of all parameters in the problem
getResiduals( 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
getChisq( problem, allpars=None ) |
---|
*** Gaussian approximation ***
Sum over the (weighted) squared residuals
Parameters
- problem : Problem
to be solved - allpars : array_like
None take parameters from problem.model
list of all parameters in the problem
toSigma( scale ) |
---|
Parameter
- scale : float
the scale of this distribution.
Return default value : scale
isBound( ) |
---|
acceptWeight( ) |
---|
True if the distribution accepts weights.
keepFixed( fixed=None ) |
---|
- Repeated calls start from scratch.
- Reset with keepFixed( fixed=None )
Parameters
- fixed : dictionary of {int:float}
int list if parameters to fix permanently. Default None.
float list of values for the fixed parameters.
setPriors( priors ) |
---|
Parameters
- priors : (list of) Prior
prior distribution for the hyperparameters
setLimits( limits ) |
---|
Parameters
- limits : [low,high]
low : float or array_like
low limits
high : float or array_like
high limits
domain2Unit( dval, ks ) |
---|
Parameters
- dval : float
hyper parameter value in domain - ks : int
selecting index
unit2Domain( uval, ks ) |
---|
Parameters
- uval : float
unit value of hyper parameter - ks : int
selecting index
logCLhood( problem, allpars ) |
---|
Parameters
- problem : Problem
to be solved - allpars : array_like
parameters of the problem
logLhood( problem, allpars ) |
---|
Parameters
- problem : Problem
to be solved - allpars : array_like
parameters of the problem
partialLogL( problem, allpars, fitIndex ) |
---|
Parameters
- problem : Problem
to be solved - allpars : array_like
parameters of the problem - fitIndex : array_like
indices of parameters to be fitted
partialLogL_alt( problem, allpars, fitIndex ) |
---|
Alternative calculation.
Parameters
- problem : Problem
to be solved - allpars : array_like
parameters of the problem - fitIndex : array_like
indices of parameters to be fitted
numPartialLogL( problem, allpars, fitIndex ) |
---|
Parameters
- problem : Problem
to be solved - allpars : array_like
parameters of the problem - fitIndex : array_like
indices of parameters to be fitted
updateLogL( problem, allpars, parval=None ) |
---|
This method provides the opportunity to optimize the logL calculation. Providing this one, automatically provides the previous one. For now it just refers to logLikelihood() itself.
Parameters
- problem : Problem
to be solved - param : array_like
parameters of the model - parval : dict of {int : float}
int index of a parameter
float (old) value of the parameter
setResult( ) |
---|
hyparname( k ) |
---|
Parameters
- k : int
index of the hyperparameter