BernoulliErrorDistribution = class BernoulliErrorDistribution(ErrorDistribution) |
|
BernoulliErrorDistribution(copy=None)
To calculate a Bernoulli likelihood for categorical True/False data.
For one residual, x, it holds
f( x ) = x if d is True
1 - x if d is False
where x needs to be between [0,1]; use the logistic function f(x) = 1/(1+exp(-x)
if necessary. And d is true if the residual belongs to the intended category.
The function is mostly used to calculate the likelihood L, or easier
to use log likelihood, logL.
logL = log( x ) if d else log( 1 - x )
Author Do Kester. |
|
- Method resolution order:
- BernoulliErrorDistribution
- ErrorDistribution
- builtins.object
Constructor:
- BernoulliErrorDistribution( copy=None )
- Constructor of Bernoulli Distribution.
Parameters
----------
copy : BernoulliErrorDistribution
distribution to be copied.
Methods defined here:
- acceptWeight()
- True if the distribution accepts weights.
Always true for this distribution.
- copy()
- Return copy of this.
- getScale( problem, allpars=None )
- Return the noise scale
Parameters
----------
problem : Problem
to be solved
allpars : array_like
None take parameters from problem.model
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
- logLikelihood_alt( problem, allpars )
- Return the log( likelihood ) for a Bernoulli distribution.
Alternate calculation.
Outside the range the likelihood is zero, so the logL should be -inf.
However for computational reasons the maximum negative value is returned.
Parameters
----------
problem : Problem
to be solved
allpars : array_like
parameters of the problem
- nextPartialData( problem, allpars, fitIndex, mockdata=None )
- Return the partial derivative of elements of the 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
mockdata : array_like
as calculated by the model
- partialLogL_alt( 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
- toSigma( scale )
- Return sigma, the squareroot of the variance.
Parameter
--------
scale : float
the scale of this Bernoulli distribution.
Methods inherited from ErrorDistribution:
- domain2Unit( dval, ks )
- getChisq( problem, allpars=None )
- getGaussianScale( problem, allpars=None )
- getResiduals( problem, allpars=None )
- hyparname( k )
- isBound()
- keepFixed( fixed=None )
- logCLhood( problem, allpars )
- logLhood( problem, allpars )
- numPartialLogL( problem, allpars, fitIndex )
- partialLogL( problem, allpars, fitIndex )
- setLimits( limits )
- setPriors( priors )
- setResult()
- unit2Domain( uval, ks )
- updateLogL( problem, allpars, parval=None )
|
|