ErrorDistribution

 
ErrorDistribution = class ErrorDistribution(builtins.object)
    ErrorDistribution(fixed=None, constrain=None, copy=None)
 
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.
 
  Constructor:
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.
Methods defined here:
acceptWeight()
True if the distribution accepts weights.
copy()
Return copy of this.
domain2Unit( dval, ks )
Return value in [0,1] for the selected parameter.
Parameters
----------
dval : float
    hyper parameter value in domain
ks : int
    selecting index
getChisq( problem, allpars=None )
Return chisq
 
*** 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
getGaussianScale( problem, allpars=None )
Return the noise scale.
 
*** 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 )
Return residuals: ydata - model.result
 
Parameters
----------
problem : Problem
    to be solved
allpars : array_like
    None take parameters from problem.model
    list of all parameters in the problem
hyparname( k )
Return name of the hyperparameter
 
Parameters
----------
k : int
    index of the hyperparameter
isBound()
True when all priors of its (hyper)parameters are bound
keepFixed( fixed=None )
Keeps (hyper)parameters fixed at the provided values.
 
1. Repeated calls start from scratch.<br>
2. 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.
logCLhood( problem, allpars )
Return the constrained log( likelihood ).
 
Parameters
----------
problem : Problem
    to be solved
allpars : array_like
    parameters of the problem
logLhood( problem, allpars )
Return the log( likelihood ).
 
Parameters
----------
problem : Problem
    to be solved
allpars : array_like
    parameters of the problem
numPartialLogL( problem, allpars, fitIndex )
Return d log( likelihood ) / dp, numerically calculated.
 
Parameters
----------
problem : Problem
    to be solved
allpars : array_like
    parameters of the problem
fitIndex : array_like
    indices of parameters to be fitted
partialLogL( problem, allpars, fitIndex )
Return the partial derivative of log( likelihood ) to the parameters.
 
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 )
Return the partial derivative of log( likelihood ) to the parameters.
 
Alternative calculation.
 
Parameters
----------
problem : Problem
    to be solved
allpars : array_like
    parameters of the problem
fitIndex : array_like
    indices of parameters to be fitted
setLimits( limits )
Set limits on the hyper parameter(s).
 
Parameters
----------
limits : [low,high]
    low : float or array_like
        low limits
    high : float or array_like
        high limits
setPriors( priors )
Set priors on the hyper parameter(s).
 
Parameters
----------
priors  : (list of) Prior
    prior distribution for the hyperparameters
setResult()
toSigma( scale )
Return sigma, the squareroot of the variance.
 
Parameter
--------
scale : float
    the scale of this distribution.
 
Return default value : scale
unit2Domain( uval, ks )
Return domain value for the selected parameter.
Parameters
----------
uval : float
    unit value of hyper parameter
ks : int
    selecting index
updateLogL( problem, allpars, parval=None )
Return a update of the log( likelihood ) given a change in a few parameter.
 
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