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

public abstract class AbstractMetropolis extends Object implements RandomVectorGenerator
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_t-1)\}\). To obtain good results, the proposal function should be such that the acceptance rate is around 50% for one-dimensional and 23% for n-dimensional 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 Details

    • AbstractMetropolis

      public AbstractMetropolis(Vector initialState, RandomNumberGenerator rng)
      Constructs a new instance with the given parameters.
      Parameters:
      initialState - the initial state of the algorithm
      rng - 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.
      Specified by:
      seed in interface Seedable
      Parameters:
      seeds - the seeds
    • nextVector

      public double[] nextVector()
      Description copied from interface: RandomVectorGenerator
      Gets the next random vector.
      Specified by:
      nextVector in interface RandomVectorGenerator
      Returns:
      the next random vector
    • nextProposedState

      protected abstract Vector nextProposedState(Vector currentState)
      Proposes a next state for the system.
      Parameters:
      currentState - the current state of the system
      Returns:
      the proposed next state
    • isProposalAccepted

      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.
      Parameters:
      currentState - the current state of the system
      proposedState - 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 N-dimensional Gaussian target distribution.
      Returns:
      the acceptance rate