Package gmisclib :: Module mcmc_idxr :: Class problem_definition
[frames] | no frames]

Class problem_definition

source code


Instance Methods
 
__init__(self)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
set_idxr(self, idxr) source code
 
plot(self, idxr, arg, pylab, inum) source code
 
do_print(self, idxr, arg, iter) source code
float
logp(self, x)
Compute the log of the probability density at x.
source code
 
logp_data_normalized(self, x)
Only define this if you can compute the actual probability density for the data given model & parameters, not just something proportional to it! To do this function, you need to be able to do the full multidimensional integral over the probability distribution!
source code
numpy.ndarray
fixer(self, x)
This is called on each candidate position vector.
source code
 
logp_prior_normalized(self, x) source code
 
logp_guts(self, idxr, data_sink=None) 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__

Class Variables
  PriorProbDist = None
Data for guessing.
Properties

Inherited from object: __class__

Method Details

__init__(self)
(Constructor)

source code 

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

Overrides: object.__init__
(inherited documentation)

logp(self, x)

source code 

Compute the log of the probability density at x.

Parameters:
  • x - 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: mcmc.problem_definition.logp
(inherited documentation)

logp_data_normalized(self, x)

source code 

Only define this if you can compute the actual probability density for the data given model & parameters, not just something proportional to it! To do this function, you need to be able to do the full multidimensional integral over the probability distribution!

NOTE that x is an indexer! NOTE that this is not the full logp function: it doesn't contain the prior!

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 - 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: mcmc.problem_definition.fixer
(inherited documentation)