Class AbstractMetropolis
java.lang.Object
dev.nm.stat.random.rng.multivariate.mcmc.metropolis.AbstractMetropolis
 All Implemented Interfaces:
RandomVectorGenerator
,Seedable
 Direct Known Subclasses:
AbstractHybridMCMC
,Metropolis
,MetropolisHastings
,RobustAdaptiveMetropolis
The Metropolis algorithm is a Markov Chain Monte Carlo algorithm, which requires only a function
f proportional to the PDF from which we wish to sample. As such it is useful for
situations where normalizing the PDF is difficult.
At each step, a proposed state is drawn as a perturbation from the current step, from a proposal
distribution. The probability of the proposed state x* being accepted is then given by
\(min\{1, f(x^*)/f(x_t1)\}\).
To obtain good results, the proposal function should be such that the acceptance rate is around
50% for onedimensional and 23% for ndimensional cases.
To use a symmetric proposal function, consider using Metropolis. For cases where it
may be difficult to choose an appropriate proposal distribution, consider using
RobustAdaptiveMetropolis. To use an asymmetric proposal distribution, consider
using MetropolisHastings.

Constructor Summary
ConstructorDescriptionAbstractMetropolis
(Vector initialState, RandomNumberGenerator rng) Constructs a new instance with the given parameters. 
Method Summary
Modifier and TypeMethodDescriptionfinal double
Gets the acceptance rate, i.e.protected abstract boolean
isProposalAccepted
(Vector currentState, Vector proposedState) Decides whether the given proposed state should be accepted, or whether the system should remain in it's current state.protected abstract Vector
nextProposedState
(Vector currentState) Proposes a next state for the system.double[]
Gets the next random vector.void
seed
(long... seeds) Seed the random number/vector/scenario generator to produce repeatable experiments.

Constructor Details

AbstractMetropolis
Constructs a new instance with the given parameters. Parameters:
initialState
 the initial state of the algorithmrng
 a random number generator


Method Details

seed
public void seed(long... seeds) Description copied from interface:Seedable
Seed the random number/vector/scenario generator to produce repeatable experiments. 
nextVector
public double[] nextVector()Description copied from interface:RandomVectorGenerator
Gets the next random vector. Specified by:
nextVector
in interfaceRandomVectorGenerator
 Returns:
 the next random vector

nextProposedState
Proposes a next state for the system. Parameters:
currentState
 the current state of the system Returns:
 the proposed next state

isProposalAccepted
Decides whether the given proposed state should be accepted, or whether the system should remain in it's current state. Parameters:
currentState
 the current state of the systemproposedState
 the proposed next state of the system Returns:
 whether the system should accept the proposed next state

acceptanceRate
public final double acceptanceRate()Gets the acceptance rate, i.e. the proportion of proposed states that have been accepted by iterators returned by this instance. This is useful for choosing an appropriate standard deviation of the proposal function. It has been shown theoretically that the ideal acceptance rate for a one dimensional Gaussian distribution is approximately 50%, decreasing to approximately 23% for an Ndimensional Gaussian target distribution. Returns:
 the acceptance rate
