The Metropolis–Hastings algorithm proposes from at state and accepts it with probabilityThis acceptance rule enforces detailed balance with the target density .
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 .
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.
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.