class BernoulliErrorDistribution( ErrorDistribution ) | Source |
---|
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.
BernoulliErrorDistribution( copy=None ) |
---|
Constructor of Bernoulli Distribution.
Parameters
- copy : BernoulliErrorDistribution
distribution to be copied.
copy( ) |
---|
acceptWeight( ) |
---|
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
toSigma( scale ) |
---|
- scale : float
the scale of this Bernoulli distribution.
logLikelihood_alt( problem, allpars ) |
---|
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
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 ) |
---|
Parameters
- problem : Problem
to be solved - allpars : array_like
parameters of the problem - fitIndex : array_like
indices of parameters to be fitted
nextPartialData( problem, allpars, fitIndex, mockdata=None ) |
---|
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
Methods inherited from ErrorDistribution |
---|
- getGaussianScale( problem, allpars=None )
- getResiduals( problem, allpars=None )
- getChisq( problem, allpars=None )
- isBound( )
- keepFixed( fixed=None )
- setPriors( priors )
- setLimits( limits )
- 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 )