Skip to content
BIASED

Markov chain Monte Carlo

Block 1 of 8~2 min

A density known up to a constant

The topic Monte Carlo methods turned an expectation into an average of independent samples, with an error of about σ/n\sigma/\sqrt n. Its samplers need either a formula for the inverse CDF or a proposal qq close to the target, and rejection and importance sampling both degrade quickly as the dimension grows. The topic ended with the hard case: a density known only up to a constant.

In Bayesian statistics this case is the rule. Take the coin with unknown bias θ\theta from the topic Bayesian inference: 7 heads in 10 tosses and a uniform prior. Bayes' formula gives the posterior as prior times likelihood, divided by the evidence:

p(θ)=p~(θ)Z,p~(θ)=θ7(1−θ)3,Z=∫01p~(θ) dθ.p(\theta) = \frac{\tilde p(\theta)}{Z}, \qquad \tilde p(\theta) = \theta^7 (1 - \theta)^3, \qquad Z = \int_0^1 \tilde p(\theta)\, d\theta .

Here ZZ happens to have a formula: the posterior is Beta⁡(8,4)\operatorname{Beta}(8, 4) with mean 2/32/3, and that lets us check every answer below. Replace the uniform prior by one without a conjugate partner, or the coin by a logistic regression with a hundred weights, and ZZ becomes an integral over a hundred dimensions that nobody can compute. The unnormalized density p~\tilde p stays cheap: one factor per observation.

What can we do with p~\tilde p alone? We can compare two points. The constant cancels in a ratio:

p(y)p(x)=p~(y)/Zp~(x)/Z=p~(y)p~(x).\frac{p(y)}{p(x)} = \frac{\tilde p(y)/Z}{\tilde p(x)/Z} = \frac{\tilde p(y)}{\tilde p(x)} .

We know how many times more probable one point is than another, but not how probable either of them is.

The topic Markov chains supplies the other half. By the ergodic theorem, one long run of an irreducible chain spends in each state a share of time equal to its stationary probability, and averages along the run converge to expectations under π\pi. Read backwards: if we build a chain whose stationary distribution is pp, running it produces samples from pp. This is Markov chain Monte Carlo (MCMC). The whole topic is about building such a chain from ratios of p~\tilde p.

Answers are saved on the server and tied to this browser until you sign in.