On a finite state space with finite objective function values, the fixed- target is a Boltzmann distribution:
The partition function normalizes the weights but cancels from the Metropolis–Hastings acceptance probability. A short detailed balance proof explains the target. With symmetric and ,
Summing over gives , so this is a stationary distribution. On a finite state space, a connected graph of positive symmetric proposals makes the accepted Markov chain an irreducible Markov chain. Convergence from any starting state additionally requires an aperiodic Markov chain; one positive self-transition suffices under irreducibility. Replacing by ensures this. For asymmetric , require connectivity through bidirectional proposals: one-way proposals are rejected.[ref]
In the five-state barrier example for simulated annealing, gives exact Boltzmann weights . Multiplying by gives
For the uphill edge, detailed balance is visible numerically:
Thus the global minimum has the largest individual stationary probability, , but is far from certain at this positive . At the exact stationary distribution is .
Figure 1.
Lower temperature concentrates equilibrium weights while suppressing uphill acceptance
. Exact Boltzmann distributions for the chosen five-state objective function, and the uphill acceptance probability conditional on the proposal . The one-step transition probability is half that acceptance probability. The bars describe equilibrium at each fixed temperature, not the evolving probability distribution during cooling. Details.
For any finite , let be the set of global minima and the smallest objective function value. Cancelling from numerator and denominator shows that each nonminimal state's weight tends to zero as , while every state in has equal weight. Therefore tends to the uniform distribution on . This is a statement about a family of equilibrium probability distributions; it does not prove that a cooling Markov chain follows that family.
A valid symmetric proposal distribution is with on the entire real line. Reject immediately if . Otherwise use the positive-parameter random walk with boundary rejection. With
the Metropolis–Hastings acceptance probability is
No Jacobian determinant is needed for this additive proposal in . Do not repeatedly redraw until : that would create a state-dependent truncated proposal and require an additional Hastings correction. Alternatively a symmetric walk in respects positivity, but then the transformed target has a factor ; equivalently the acceptance ratio in variance coordinates has the extra factor .
Hold all parameters except fixed and propose with . This Random-walk Metropolis algorithm has a symmetric proposal distribution. Define
Cancellation of unchanged likelihood and prior factors gives the Metropolis–Hastings acceptance probability
Draw an independent uniform and accept if it is at most ; otherwise retain the old value. Update each component in turn, recomputing the needed mixture contributions. On a logarithmic scale, compare with to avoid numerical underflow.
Represent a schedule by a permutation , with . Choose and reverse the block . This is a 2-opt move on the dummy tour. Its exact setup-cost change is the asymmetric 2-opt reversal cost
The internal sum matters because the specified changeovers need not be symmetric. When the block begins at the first job, the boundary terms correctly update the initial setup; the dummy return costs are zero. Processing times cancel.
At temperature , simulated annealing accepts a move with probability
With uniformly sampled reversal pairs the proposal is symmetric, so this is the appropriate Metropolis–Hastings acceptance probability. Improvements and ties are always accepted; occasional uphill moves escape local minima. Repeatedly sample moves, gradually lower , and retain the best schedule seen even if the current schedule worsens. Reversing a block of length two swaps adjacent jobs, so these moves connect the whole permutation space. A cooling schedule, iteration budget and restarts control practical performance. This is a heuristic at a finite budget; it does not certify global optimality unless paired with an exact bound or an appropriate limiting convergence argument.
A random-walk update proposes , with an increment distribution independent of the current state. If its density is symmetric, , reducing the Metropolis–Hastings acceptance probability to . For nonsymmetric increments the proposal-density ratio must remain.
Such updates need little global knowledge of the target and adapt naturally to its local scale. Their limitation is a tuning tradeoff: very small increments accept often but move slowly, while very large increments are often rejected. They can also have difficulty moving between distant modes. Covariance-scaled increments help with anisotropic targets, but the chain still explores through local steps.
The proposal must connect the whole positive posterior support by moves with nonzero reverse probability. Use the full Metropolis–Hastings acceptance probability for asymmetric proposals; dropping the reverse proposal factor generally targets the wrong distribution. Compute likelihoods and acceptance ratios on a logarithmic scale to avoid overflow and underflow, and handle zero weights explicitly. A lazy step prevents periodicity when distributional convergence is needed.
Finite-chain convergence does not guarantee a useful run length: separated modes and narrow bottlenecks can make mixing extremely slow. Tune proposals to explore efficiently, inspect several starting points and chains, and assess autocorrelation and Monte Carlo uncertainty rather than treating correlated draws as independent observations. Discarding an initial segment can reduce initialization effects, but diagnostics do not prove that every posterior mode has been visited. Thinning is not required for correctness and often throws away useful information. The model and prior must themselves be specified correctly; an exact sampler from an incorrect posterior cannot repair the model.
Both the Metropolis–Hastings algorithm and the Gibbs sampler construct a Markov chain with a specified target distribution, usually a posterior distribution known only up to normalization. For a proposal density and target density , the Metropolis–Hastings acceptance probability is
After drawing , move there with this probability; otherwise stay at . The unknown normalizing constant of cancels. The original Metropolis algorithm uses a symmetric proposal, , so the proposal-density ratio disappears. The general Metropolis–Hastings algorithm permits nonsymmetric proposals and needs that correction.
A Gibbs sampler instead chooses a coordinate or block and draws directly from its full conditional distribution, leaving the other coordinates fixed. It is exactly a conditional Metropolis–Hastings update whose proposal is that full conditional. For a change from to with fixed, the acceptance ratio is
Thus a Gibbs update is an always-accepted Metropolis–Hastings update with the full conditional as proposal. This statement concerns each update: a systematic sweep of several Gibbs kernels preserves the target but need not itself be reversible.
When the full conditional distributions are easy to sample, a Gibbs sampler avoids proposal tuning and rejection, and is particularly convenient for conjugate priors and data augmentation. When a conditional cannot be sampled directly, a Metropolis–Hastings algorithm can use only its evaluable density; such an update can also be inserted into a Gibbs sweep. Block or joint Metropolis–Hastings proposals can move efficiently along strongly correlated directions for which coordinate-wise Gibbs updates mix slowly. Conversely, a badly chosen Metropolis–Hastings proposal can reject most moves or make only tiny moves. Acceptance probability one by itself does not guarantee rapid exploration. Both methods require appropriate irreducibility and convergence checks before their long-run averages are useful posterior estimates.
First require a proper target: and . The Metropolis–Hastings algorithm uses the Metropolis–Hastings acceptance probability
Sufficient general conditions are phi-irreducibility, aperiodicity, and a drift-minorisation condition establishing geometric ergodicity of the resulting chain, together with a stationary th moment for the observable being averaged. These imply the central limit theorem for a geometrically ergodic Markov chain. The observable's moment condition must be included: conditions on the sampler alone cannot give the theorem for every arbitrary function.
A concrete stronger condition, directly in terms of the proposal, is
Together with a bounded observable, this is an especially simple sufficient answer. The accepted proposal density is , so it is at least . The kernel satisfies a global minorization condition with the target, hence uniform geometric ergodicity, positive Harris recurrence, and aperiodicity. An independent proposal whose importance weight is uniformly bounded is one example. No claim of these properties follows merely from writing down a positive proposal.
For the off-diagonal moves, the Metropolis–Hastings acceptance probability gives
This expression is unchanged by interchanging and . The rejected-move measure is supported on the diagonal and is also symmetric. Therefore the whole transition measure satisfies
which proves detailed balance, including the atom that an off-diagonal density alone would omit. Consequently the Metropolis–Hastings algorithm kernel preserves the normalized target measure.
Let and . With conditional independence of the binary observations given the latent function, define
The prior distribution is specified on the precision , not on . Its Jacobian determinant gives
and the marginal posterior density is proportional to . Working instead with precision or logarithmic coordinates is possible, provided all corresponding Jacobian determinants are included.
Choose an importance sampling density covering the support of , draw independently from it, and use the nonnegative unbiased likelihood estimator
Each summand integrates to , proving unbiasedness. A simple always-valid choice is the latent Gaussian prior distribution, , when the covariance matrix is nonsingular. Then the estimator is just the average of the bounded values . For duplicate inputs, sample only the distinct latent values and multiply all likelihood contributions at each common input. A Gaussian approximation to the latent posterior distribution, or its mixture with the Gaussian prior distribution, can reduce relative variance while keeping complete support. Its approximation does not replace the exact weights.
The pseudo-marginal Metropolis–Hastings algorithm stores both the current and its estimator randomness ; write their sampling law as . Propose , independently generate , compute , and accept the pair with
Here denotes the proposal probability density function from to . On rejection retain both the old parameter and the old likelihood estimate. Initialize with a positive estimate. One must not independently refresh the denominator after rejection.
Correctness follows from the extended posterior density
The pair proposal is . Its Metropolis–Hastings acceptance probability simplifies to the displayed ratio, since the auxiliary densities cancel. Hence detailed balance holds for . Integrating over gives by unbiasedness, so the parameter marginal distribution is exactly the intended posterior distribution for any fixed positive . This is exactness of the stationary target, not independent exact samples or a guarantee of rapid convergence. Large relative variance of the likelihood estimates can produce long holding times, so marginalizing does not by itself guarantee an improvement in mixing time.
Let
be the Hamiltonian. The Hamiltonian Monte Carlo proposal is accepted with the Metropolis–Hastings acceptance probability
The leapfrog map is volume preserving and reversible after momentum reversal, so no proposal-density Jacobian appears.
Let be the likelihood function. Since the prior distribution is , the posterior density has the form
where is the normalizing constant.
Choose and use the Gaussian autoregressive proposal reversible with respect to a standard normal distribution
Thus
whose covariance matrix is the required . Reversibility with respect to the standard normal distribution says
so
The Metropolis–Hastings acceptance probability therefore reduces to
This is the Preconditioned Crank–Nicolson algorithm with proposal scale .
Hamiltonian Monte Carlo augments the position by an independent momentum and uses the Hamiltonian function
From the current , draw a fresh , apply a fixed number of leapfrog steps to approximate Hamiltonian flow, and obtain . The Metropolis–Hastings acceptance probability is
otherwise retain . Momentum negation may be included to make the proposal explicitly reversible. The leapfrog map is volume preserving and reversible, while the acceptance step corrects its discretization error, leaving invariant after the momentum is discarded.
Preconditioned Crank–Nicolson algorithm Created 2026-09-29 Updated 2026-10-03
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.
Proposal distribution 2026-09-29
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.
Pseudo-marginal Metropolis–Hastings algorithm Created 2026-10-06 Updated 2026-10-14
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.
Simulated annealing Created 2026-10-14 Updated 2026-10-18
Simulated annealing accepts worse feasible solutions to escape a local minimum. Minimize an objective function , analogous to energy. Effective temperature has the same units as , absorbing the Boltzmann constant; it controls exploration, rather than a material's thermodynamic temperature.[ref]
Given current feasible point , draw from a proposal distribution . For a symmetric proposal distribution, , use the Metropolis–Hastings acceptance probability
Accept with this conditional probability; on rejection retain . Every downhill or equal-cost proposal is accepted. Draw a fresh uniform random variable on and accept if . The off-diagonal transition probability includes proposing .[ref]
For a maximization problem with objective function , set : every improving proposed neighbor is accepted, and a worsening move of loss has conditional probability of acceptance, under the same symmetry assumption. Likelihood-power annealing uses precisely this sign convention for a log-likelihood. Retain the best feasible solution seen, since the current state can worsen even after a global minimum has been visited.
If the proposal distribution is asymmetric, use the full Metropolis–Hastings acceptance probability, for ,
A missing reverse proposal gives zero acceptance. Even a downhill proposal need not be accepted with probability one in this case. Choosing uniformly among a variable number of neighbors is generally asymmetric: and give the correction , where is vertex degree.[ref]
The useful idea is to separate exploring from insisting on improvement: an uphill move can open a route to a better feasible solution. Its usefulness depends on the proposal distribution, the scale of the objective function, and the cooling schedule for simulated annealing. Finite practical schedules carry no general guarantee of finding a global minimum.
Surrogate Hamiltonian Monte Carlo uses an auxiliary smooth probability density function to generate trajectories but applies a Metropolis–Hastings acceptance probability using the intended target . For Gaussian momenta and an involutive Metropolis proposal generated by flipped leapfrog integration, the acceptance probability is . Only the surrogate gradient is required during the trajectory; target density evaluations are still required at the endpoints.
To minimize over models with different parameter dimensions, sample from a target proportional to and cool . A dimension-matching proposal augments the smaller model by auxiliary variables, transforms them bijectively into the larger parameter vector, and includes the proposal probability density function and absolute Jacobian determinant in the Metropolis–Hastings acceptance probability. For a positive Poisson mean and normal parameters , one convenient transformation is
Its absolute Jacobian determinant is one. If the forward and reverse model-jump selection probabilities are and , the Poisson-to-normal ratio is
The reverse ratio is its reciprocal at the inverse map. This enforces detailed balance. When the target is proper and the annealing chain explores it adequately, the low-temperature laws concentrate on the minimum Akaike information criterion, rather than the maximum marginal model evidence. Likelihoods compared across models must describe the same observed data with a compatible reference measure.