class Prior( object ) | Source |
---|
Base class defining prior distributions.
Two methods need to be defined in specific priors which map the values between [0,1] on to the domain, and vice versa unit2Domain and domain2Unit.
u = domain2Unit( d )
d = unit2Domain( u )
d is a value in the domain of the prior and u is a vlue in [0,1]
The handling of limits is relegated to this Prior class.
Define
umin = domain2Unit( lowLimit )
urange = domain2Unit( highLimit ) - umin
u = ( domain2Unit( d ) - umin ) / urange
d = unit2Domain( u * urange + umin )
Symmetric priors can be used in a circular variant; i.e. the low and high limits are folded on each other, provided that the limit values are the same (hence symmetric)
u = limitedDomain2Unit( d ) + 1 ) / 3
d = limitedUnit2Domain( ( u * 3 ) % 1 )
The copy method is also necessary.
Attributes
- lowLimit : float
low limit on the Prior - highLimit : float
high limit on the Prior - deltaP : float
width of numerical partial derivative calculation - circular : bool or float
whether circular
Hidden Attributes
- _lowDomain : float
lower limit of the Priors possible values - _highDomain : float
upper limit of the Priors possible values - _umin : float
umin lowLimit in unit - _urng : float
urange (hi-lo) in unit
Prior( limits=None, circular=False, domain=[-math.inf,math.inf], prior=None ) |
---|
Default constructor.
Parameters
- limits : None or list of 2 floats
2 limits resp. low and high - circular : bool or float
False not circular
True circular with period from limits[0] to limits[1]
period of circularity - domain : 2 floats
over which the prior is defined - prior : Prior
prior to copy (with new limits if applicable)
copy( ) |
---|
limitedIntegral( center=0, circular=False, limits=None ) |
---|
Parameters
- center : float
of the prior - circular : bool or float
bool : y|n circular with period from limits[0] to limits[1]
float :period of circularity - limits : None or list of 2 float/None
None : no limits.
2 limits, resp low and high
setLimits( limits=None ) |
---|
Parameters
- limits : None or list of any combination of [None, float]
None : no limit (for both or one)
float : [low,high] limit
Raises
ValueError when low limit is larger than high limit or out of Domain
setPriorAttributes( limits, circular ) |
---|
Parameters
- limits : None or array of 2 floats
defining the period - circular : bool or float
False pass
True Calculate period and center from limits
float period
isCircular( ) |
---|
limitedDomain2Unit( dval ) |
---|
limitedUnit2Domain( uval ) |
---|
circularDomain2Unit( dval ) |
---|
circularUnit2Domain( uval ) |
---|
unsetLimits( ) |
---|
setAttributes( limits=None, scale=None ) |
---|
Parameters
- limits : float or None
[low,high] limit - scale : float or None
scale factor
isOutOfLimits( par ) |
---|
Parameters
- par : float or array_like
the parameter to check
checkLimit( par ) |
---|
Parameters
- par : float
the parameter to check
Raises
ValueError when outside limits.
stayInLimits( par ) |
---|
Parameters
- par : float
the parameter to check
hasLowLimit( ) |
---|
Return true if the prior has its low limits set.
hasHighLimit( ) |
---|
Return true if the prior has its high limits set.
hasLimits( ) |
---|
Return true if it has any limits.
getLimits( ) |
---|
getIntegral( ) |
---|
Default: 1.0 (for bound priors)
getRange( ) |
---|
domain2Unit( dval ) |
---|
Parameters
- dval : float
value within the domain of a parameter
unit2Domain( uval ) |
---|
Parameters
- uval : float
value within [0,1]
result( p ) |
---|
If result is not defined, fall back to numerical derivative of Domain2Unit.
Parameters
- p : float
the value
partialDomain2Unit( p ) |
---|
Parameters
- p : float
the value
logResult( p ) |
---|
Parameters
- p : float
the value
numPartialDomain2Unit( dval ) |
---|
Parameters
- dval : float
value within the domain of a parameter
partialLog( p ) |
---|
Parameters
- p : float
the value
numPartialLog( p ) |
---|
- p : float
the value
isBound( ) |
---|
Return true if the integral over the prior is bound.