MeanWalker
Public Member Functions | Protected Member Functions

meanwalker::MetropolisWalker Class Reference

This class implements the Metropolis-Hastings method for taking samples from a particular probability distribution. More...

#include <metropoliswalker.h>

Inheritance diagram for meanwalker::MetropolisWalker:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 MetropolisWalker (RandomNumberGenerator *pRndGen)
 Constructor, in which you need to specify the random number generator to be used.
bool init (Function *pProbFunction, const double *pMinCoords, const double *pMaxCoords, const double *pStartCoords, bool keepInside=true)
 Initialize the sampler.
void setNewStartCoordinates (double *pStartCoords)
 Set this position as the current position of the walker.

Protected Member Functions

virtual void stepToNewCoords (const double *pCurCoords, double *pNewCoords)
 By overriding this function, you can change the way the walker steps to a new coordinate (be careful if you change this, without obeying certain rules, the underlying probability distribution will not be sampled correctly).

Detailed Description

This class implements the Metropolis-Hastings method for taking samples from a particular probability distribution.

This class implements the Metropolis-Hastings method for taking samples from a particular probability distribution. Is does this by creating a 'walker', an item which performs a sort of biased random walk, so that it takes samples from the specified distribution. The probability distribution can be specified either by itself, or as the logarithm of the distribution. In the first case, multiplication by a constant factor doens't matter (i.e. it doesn't have to be normed), which in the second case means that adding a specific constant does not matter.


Constructor & Destructor Documentation

meanwalker::MetropolisWalker::MetropolisWalker ( RandomNumberGenerator pRndGen)

Constructor, in which you need to specify the random number generator to be used.


Member Function Documentation

bool meanwalker::MetropolisWalker::init ( Function pProbFunction,
const double *  pMinCoords,
const double *  pMaxCoords,
const double *  pStartCoords,
bool  keepInside = true 
)

Initialize the sampler.

Initialize the sampler.

Parameters:
pProbFunctionThe probability density to be sampled.
pMinCoordsSets the minimum coordinates which are used together with the maximum coordinates to calculate the scale of the steps used in the random walk.
pMaxCoordsSets the maximum coordinates which are used together with the minimum coordinates to calculate the scale of the steps used in the random walk.
pStartCoordsIf not null, the walker will start at these coordinates. If null, a random position between pMinCoords and pMaxCoords is used as starting point.
keepInsideIf true, the random walk is not allowed to go beyond the boundaries specified by the minimum coordinates. If false, the walker can go outside these bounds. In that case the boundaries are only used to calculate the step size.
void meanwalker::MetropolisWalker::setNewStartCoordinates ( double *  pStartCoords)

Set this position as the current position of the walker.

virtual void meanwalker::MetropolisWalker::stepToNewCoords ( const double *  pCurCoords,
double *  pNewCoords 
) [protected, virtual]

By overriding this function, you can change the way the walker steps to a new coordinate (be careful if you change this, without obeying certain rules, the underlying probability distribution will not be sampled correctly).


The documentation for this class was generated from the following file: