How does the Metropolis–Hastings acceptance probability follow from detailed balance, and why is Gibbs sampling a special case whose proposals are always accepted?

Probabilistic models, MCMC
Level L4 Advanced. Length Long. Nature Mat Mathematical.

What's being asked

Whether you can build a Markov chain with a prescribed stationary distribution, and connect the two standard MCMC algorithms.

Key idea

With proposal q(x′∣x) and target π, accepting with A(x→x′)=min⁡(1,π(x′) q(x∣x′)π(x) q(x′∣x)) gives π(x) q(x′∣x) A(x→x′)=π(x′) q(x∣x′) A(x′→x), which is detailed balance, so π is stationary. For Gibbs, q(x′∣x)=π(xj′∣x−j) with x−j′=x−j, where x−j means all coordinates except j, and the ratio is exactly 1.

Steps

  1. Show that detailed balance π(x)T(x′∣x)=π(x′)T(x∣x′) implies stationarity: summing over x gives ∑xπ(x)T(x′∣x)=π(x′)∑xT(x∣x′)=π(x′).
  2. For x′≠x the MH kernel is T(x′∣x)=q(x′∣x) A(x→x′). Detailed balance requires A(x→x′)A(x′→x)=π(x′) q(x∣x′)π(x) q(x′∣x)=:ρ Only the ratio of the two acceptance probabilities is fixed, so we still have a free choice.
  3. Choose the largest acceptance probabilities with this ratio: if ρ≤1, set A(x→x′)=ρ and A(x′→x)=1; if ρ>1, the reverse. Both cases are A=min⁡(1,ρ). Rejected moves keep the chain at x, which does not affect detailed balance for x′≠x.
  4. Note that π enters only as a ratio, so its normalising constant is not needed. For a symmetric proposal the ratio is π(x′)/π(x) (the Metropolis algorithm).
  5. Gibbs: update coordinate j by proposing xj′∼π(xj′∣x−j) and keeping x−j′=x−j. Write π(x)=π(xj∣x−j) π(x−j). Then ρ=π(xj′∣x−j) π(x−j)⋅π(xj∣x−j)π(xj∣x−j) π(x−j)⋅π(xj′∣x−j)=1, so every proposal is accepted.
  6. Say what else convergence needs: irreducibility and aperiodicity, so that the stationary distribution is unique and the chain approaches it; in practice, burn-in and autocorrelation.

Common mistakes

How long your answer should be

About a page; 8–10 minutes.

Last checked on 4 December 2026.

Read this

Previous in Probabilistic models: An MCMC chain has n=10,000 post-burn-in draws of a quantity with variance σ2=1 and autocorrelations ρk=0.9k. What is the effective sample size neff, how does the Monte Carlo standard error compare with the naive σ/n, and what happens to the information if you thin the chain by keeping every 20th draw?
Next in Probabilistic models: In mean-field variational inference, with q(z)=∏jqj(zj), show that the optimal factor satisfies ln⁡qj∗(zj)=Ei≠j[ln⁡p(x,z)]+const. How is this used as an algorithm?