The Metropolis–Hastings algorithm proposes from at state and accepts it with probabilityThis acceptance rule enforces detailed balance with the target density .
The Metropolis algorithm is the symmetric-proposal case of the Metropolis–Hastings algorithm. At state with positive target density , propose from with , and accept with probabilityOtherwise remain at . A normalizing constant in cancels, which makes the method useful when a target distribution is known only up to scale.
The accepted probability flow is , symmetric in . This proves detailed balance and hence invariance of the target under the usual kernel assumptions.
For two states with target masses and an always-flip proposal, moves from the first state are always accepted, while reverse moves are accepted with probability . The rejection probability creates holding at the second state. Target invariance alone does not prove convergence from every start; irreducibility and appropriate periodicity conditions matter. An asymmetric proposal requires the Hastings proposal-density correction.
The Barker acceptance probability accepts a proposal using the displayed ratio. If and , the accepted flux is , symmetric in the two states. This proves detailed balance; define acceptance as zero when . Rejected proposals contribute to the diagonal transition probability. Replacing by an unnormalized target leaves the ratio unchanged. For a common proposal, shows that its acceptance probability never exceeds the Metropolis–Hastings acceptance probability. The name refers to A. A. Barker's work on Monte Carlo methods for a plasma; the initials are retained without an unverified expansion.[ref]
Monte Carlo Calculations of the Radial Distribution Functions for a Proton-Electron Plasma by A. A. Barker. Australian Journal of Physics 18, 119–134 (1965), bibliographic provenance
Represent a size- subset of objects by a binary vector with coordinate sum , where . Uniformly choosing one occupied and one unoccupied coordinate and swapping them gives equally likely neighbours. This proposal distribution is symmetric, so its forward and reverse factors cancel in the Metropolis–Hastings acceptance probability. Every state is connected to every other by a sequence of swaps, establishing an irreducible Markov chain when the target masses are positive. Symmetry and the acceptance rule give detailed balance with that target.
For a discrete uniform distribution as the prior distribution and a multivariate normal distribution for observations with covariance matrix and mean , the posterior distribution is proportional to . If , expanding the quadratic forms gives log acceptance ratio , and the log acceptance probability is its minimum with zero.
A Metropolis-within-Gibbs sweep updates one coordinate or block at a time by a Metropolis–Hastings algorithm transition whose invariant law is that block's full conditional distribution. For a proposal changing only block , the acceptance ratio uses the full joint target with the other coordinates fixed, together with the reverse/forward proposal ratio. Each block kernel preserves the joint posterior, so their composition does as well. Conjugate blocks can instead use exact Gibbs sampling draws. Systematic composition need not be reversible, even when every block kernel is reversible.
A pseudo-marginal Metropolis–Hastings algorithm replaces an intractable likelihood function by a nonnegative unbiased likelihood estimator and includes its auxiliary randomness in the state. If for , the extended target is proportional to . An independence proposal for new auxiliary randomness cancels the factors in the Metropolis–Hastings acceptance probability. On rejection the old estimate must be retained. Integrating the extended target gives the desired marginal posterior distribution exactly.
An unbiased likelihood estimator has expectation equal to the likelihood function at each parameter. A pseudo-marginal algorithm requires this estimator to be nonnegative. Importance sampling provides for independent random variables , provided the proposal covers the target support. Relative variance affects the mixing time even though unbiasedness guarantees the correct marginal target.
At the current state , a Metropolis–Hastings algorithm draws a candidate state from its proposal distribution . The Metropolis–Hastings acceptance probability corrects the proposal's bias so that the target distribution remains invariant.
An involutive Metropolis proposal uses a deterministic bijection satisfying . For a volume-preserving and target probability density function , accept with probability . The identity and a change of variables under prove detailed balance. A non-unit Jacobian determinant must be included when volume is not preserved.
For a proposal , with isotropic and an independent random orthogonal matrix , invariance of the distribution of under transpose makes the proposal distribution symmetric. Indeed , and averaging the isotropic Gaussian density over an inversion-invariant law yields . The Metropolis–Hastings algorithm therefore accepts with the target density ratio alone.
Let , let , and proposeThe proposal distribution is . If independently of , then is a jointly multivariate normal distribution invariant under exchanging and , because both random vectors have covariance matrix and their cross-covariance matrices are both . Consequently its density satisfieswhere is the standard-normal density. Thus the proposal is reversible with respect to the standard normal distribution.
The preconditioned Crank–Nicolson algorithm, or pCN algorithm, uses a Gaussian autoregressive proposal reversible with respect to a standard normal distribution in a Metropolis–Hastings algorithm. When the target density is a likelihood times the proposal's invariant Gaussian prior density, the Gaussian factors cancel from the Metropolis–Hastings acceptance probability, leaving the likelihood ratio.
Random-walk Metropolis proposes a symmetric increment from the current state and accepts a proposal from with probability .
A Poisson Metropolis chain samples a Poisson distribution by proposing an upward or downward unit step with equal probability and reflecting a downward proposal at zero into a self-proposal. Its upward and downward transition probabilities are the displayed , with , and the diagonal entry is . For , adjacent stationary fluxes equal . Hence detailed balance holds. Positive adjacent probabilities imply an irreducible Markov chain; implies aperiodicity. The normalized invariant Poisson distribution implies positive recurrence, so the countable-state Markov chain convergence theorem applies. The boundary proposal probability is essential: forcing every proposal at zero to go upward would require a different acceptance ratio.
To update a positive parameter, a symmetric additive proposal distribution can be generated on the whole real line. Reject nonpositive proposals; accept positive ones using the target density ratio. The off-diagonal proposal remains symmetric. Repeatedly redrawing until the proposal is positive instead truncates and renormalizes the proposal differently at different current states, so a Hastings correction is then required. A symmetric walk in is another valid method, but its transformed target includes the Jacobian determinant factor .
A small proposal scale increases acceptance while making successive states almost equal. A large scale often proposes low-density states and creates long rejection runs. A pilot comparison can optimize effective sample size of a Markov chain per unit computing time, or expected accepted squared displacement, rather than acceptance alone. Tune on representative functions and then fix the scale for production; an arbitrarily history-dependent adaptation is not automatically a chain with the desired invariant distribution.
An independence Metropolis–Hastings algorithm proposes from a fixed density independent of the current state. If , it is uniformly and hence geometrically ergodic.
If a Metropolis–Hastings algorithm proposes fresh draws from its target stationary distribution , its acceptance ratio on the positive support is . Therefore every proposal is accepted, and . From the first update onward the recorded states are independent and identically distributed random variables with law , regardless of the initial state in the support. An arbitrary initial state is excluded when claiming an unbiased finite-sample average.
Articles by others on the same topic
The Metropolis–Hastings algorithm is a Markov Chain Monte Carlo (MCMC) method used for sampling from probability distributions that are difficult to sample from directly. It is particularly useful in situations where the distribution is defined up to a normalization constant, making it challenging to derive samples analytically.