Prior

 
Prior = class Prior(builtins.object)
    Prior(limits=None, circular=False, domain=[-inf, inf], prior=None)
 
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 )
    _urng = 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
 
  Constructor:
Prior( limits=None, circular=False, domain=[-inf, 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)
Methods defined here:
checkLimit( par )
Check whether the parameter is within limits.
 
Parameters
----------
par : float
    the parameter to check
 
Raises
------
    ValueError when outside limits.
circularDomain2Unit( dval )
circularUnit2Domain( uval )
copy()
Return a copy
domain2Unit( dval )
Return a value in [0,1] given a value within the valid domain of
a parameter for a distribution.
 
Parameters
----------
dval : float
    value within the domain of a parameter
getIntegral()
Return the integral of the prior over the valid range.
 
Default: 1.0 (for bound priors)
getLimits()
Return the limits.
getRange()
Return the range.
hasHighLimit()
Return true if the prior has its high limits set.
hasLimits()
Return true if it has any limits.
hasLowLimit()
Return true if the prior has its low limits set.
isBound()
Return true if the integral over the prior is bound.
isCircular()
Whether circular
isOutOfLimits( par )
True if the parameter is out of limits
 
Parameters
----------
par : float
    the parameter to check
limitedDomain2Unit( dval )
Shrink domain to value in [0,1]
limitedUnit2Domain( uval )
Expand value in [0,1] to domain
logResult( p )
Return the log of the result; -inf when p == 0.
 
Parameters
----------
p : float
    the value
numPartialDomain2Unit( dval )
Return a the numeric derivate of the domain2Unit function to dval.
 
Parameters
----------
dval : float
    value within the domain of a parameter
numPartialLog( p )
Return the numeric partial derivative of log( Prior ) wrt parameter.
Parameters
----------
p : float
    the value
partialDomain2Unit( p )
Return the derivative of Domain2Unit, aka the result of the distribution at p
 
Parameters
----------
p : float
    the value
partialLog( p )
Return partial derivative of log( Prior ) wrt parameter.
default numPartialLog
 
Parameters
----------
p : float
    the value
result( p )
Return value of the Prior at a given value.
 
If result is not defined, fall back to numerical derivative od Domain2Unit.
 
Parameters
----------
p : float
    the value
setAttributes( limits=None, scale=None )
Set possible attributes for a Prior.
 
Parameters
----------
limits : float or None
    [low,high] limit
scale : float or None
    scale factor
setLimits( limits=None )
Set limits.
It is asserted that lowLimit is smaller than highLimit.
 
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 )
stayInLimits( par )
Return lower limit or upper limit when parameter is outside.
 
Parameters
----------
par : float
    the parameter to check
unit2Domain( uval )
Return a value within the valid domain of the parameter given a value
between [0,1] for a distribution.
 
Parameters
----------
uval : float
    value within [0,1]
unsetLimits()
Remove all limits.