Unit content
Metropolis-Hastings sampling
Many probability distributions are known only up to a normalization constant or live in spaces too large for direct sampling. Metropolis-Hastings constructs a Markov chain whose stationary distribution is the desired target $\pi(x)$.
From the current state $x$, propose a candidate $x'$ from a proposal distribution $q(x'\mid x)$. Accept it with probability $$\alpha=\min\left(1,\frac{\pi(x')q(x\mid x')}{\pi(x)q(x'\mid x)}\right).$$ If the move is rejected, keep the current state. For a symmetric proposal $q(x'\mid x)=q(x\mid x')$, this simplifies to $$\alpha=\min\left(1,\frac{\pi(x')}{\pi(x)}\right).$$
In a canonical statistical-mechanics system, $\pi(x)\propto e^{-\beta E(x)}$. For a proposed move with energy change $\Delta E=E'-E$, $$\alpha=\min(1,e^{-\beta\Delta E}).$$ Moves that lower energy are always accepted; moves that raise energy can still occur, with probability suppressed by the Boltzmann factor.
For example, if $\beta\Delta E=2$, an uphill move is accepted with probability $e^{-2}\approx0.135$. Repeated accepted and rejected moves allow the chain to explore both common low-energy configurations and rarer thermal fluctuations.
Successive states of the chain are generally correlated, so $N$ recorded steps do not contain the same information as $N$ independent samples. A useful chain must move between the important regions of the target distribution often enough that initial conditions are forgotten and long-run averages stabilize. Running longer does not repair a chain that is effectively trapped in only one region.
Metropolis-Hastings is powerful because normalization constants cancel from the acceptance ratio. Reliable estimates still require checking that the chain has actually explored the target distribution rather than merely generated a long sequence.