Package gmisclib :: Module mcmc :: Class problem_definition_F
[frames] | no frames]

Class problem_definition_F

source code


This is a variant that is used bin the bin/mcmc.py script.

Instance Methods
 
__init__(self, logp_fcn, c, fixer=None)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
float
logp(self, x)
Compute the log of the probability density at x.
source code
numpy.ndarray
fixer(self, x)
This is called on each candidate position vector.
source code
 
log(self, p, i)
Some code calls this function every iteration to log the current state of the MCMC process. (Inherited from gmisclib.mcmc.problem_definition)
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties

Inherited from object: __class__

Method Details

__init__(self, logp_fcn, c, fixer=None)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Decorators:
  • @g_implements.make_optional
  • @g_implements.make_varargs
Overrides: object.__init__
(inherited documentation)

logp(self, x)

source code 

Compute the log of the probability density at x.

Parameters:
  • x (numpy.ndarray) - a parameter vector
Returns: float
The log of the probability that the model assigns to parameters x.
Raises:
  • NotGoodPosition - This exception is used to indicate that the position x is not valid. This is equivalent to returning an extremely negative logp.
Overrides: problem_definition.logp

fixer(self, x)

source code 

This is called on each candidate position vector. Generally, it is used to restrict the possible solution space by folding position vectors that escape outside the solution space back into the solution space. It can also allow for symmetries in equations.

Formally, it defines a convex region. All vectors outside the region are mapped into the region, and the mapping must be continuous at the boundary. (More precisely, logp(fixer(x)) must be continuous everywhere that logp(x) is continuous, including the boundary.) For instance, mapping x[0] into abs(x[0]) defines a convex region (the positive half-space), and the mapping is continuous near x[0]=0.

Additionally, it may re-normalize parameters at will subject to the restriction that logp(fixer(x))==logp(x). For instance, it can implement a constraint that sum(x)==0 by mapping x into x - average(x), so long as the value of logp() is unaffected by that substitution. Other folds can sometimes lead to problems.

Parameters:
  • x (numpy.ndarray) - a parameter vector
Returns: numpy.ndarray
a (possibly modified) parameter vector.
Raises:
  • NotGoodPosition - This exception is used to indicate that the position x is not valid. Fixer has the option of either mapping invalid parameter vectors into valid ones or raising this exception.
Overrides: problem_definition.fixer

Attention: Within a convex region (presumably one that contains the optimal x), fixer must not change the value of logp(): logp(fixer(x)) == logp(x).