Markov Chain Monte Carlo

Sampling from a posterior distribution you can't write down in closed form, by building a random walk whose long-run behavior matches that distribution.

An MCMC chain wanders through parameter space, visiting high-probability regions more often than low ones

After enough steps, the fraction of time spent in each region approximates the true posterior probability there

Definition

For most realistic Bayesian models, the posterior distribution has no closed form — there's no tidy formula to write down or compute directly. Markov Chain Monte Carlo (MCMC) sidesteps this: instead of computing the posterior exactly, it builds a random walk (a Markov chain) through parameter space that, after enough steps, visits each region with frequency proportional to its true posterior probability.

Run the chain long enough, collect the sequence of visited points, and that collection of samples is an approximation of the posterior — you can compute means, credible intervals, or any other summary directly from the samples.

Why a random walk works

Imagine wandering a hilly landscape (the posterior surface) by repeatedly proposing a nearby step, and being more likely to accept moves that go uphill (toward higher probability) than downhill. Over a long enough walk, you spend most of your time near the peaks — exactly where the posterior probability is highest — and your visited locations, taken together, approximate the shape of the whole landscape.

Try it

Why is it not enough to just run the random walk for one step and call wherever it lands "the answer"?

Solution

A single step (or even a short run) reflects mostly the starting point, not the true shape of the posterior — the chain needs time to "forget" its starting position and settle into visiting regions proportional to their actual posterior probability. This is why MCMC always involves running for many iterations and typically discarding an initial "burn-in" period before treating samples as representative.

Related concepts