Markov chain Monte Carlo (MCMC) approximates a posterior distribution p(θ|x) by sampling a high-dimensional parameter space. Construct a Markov chain whose stationary distribution is the target posterior, then let it move through the space. The fraction of time it spends near a state θ reflects that state's posterior probability. Samples from the chain can then support Monte Carlo estimates of quantities of interest. section 1.4.1 section 2.0
The central implementation choice is how to move between states:
- Gibbs sampling updates one variable at a time, drawing from its distribution conditional on the latest values of the other variables. section 2.9
- Metropolis–Hastings proposes a new state x′ from q(x′|x), then accepts or rejects it using a ratio designed to satisfy detailed balance. section 2.9
From direct sampling to high-dimensional sampling
For an exponential random variable, direct sampling starts with u drawn uniformly from (0, 1) and transforms it to −ln(1 − u)/λ using the inverse cumulative distribution function. High-dimensional posteriors motivate a different approach: construct a chain that spends more time where the target posterior is more probable. Monte Carlo exercises such as estimating π, a binomial tree model, and a self-avoiding random walk provide practice with simulation before the sampling algorithms. section 1.4.1 section 2.0
Figure 1.6 Exponential RV probability density function (left) and cumulative density function (right)
The exponential density and cumulative distribution illustrate the low-dimensional inverse-CDF method used as a contrast to sampling a high-dimensional posterior. section 1.4.1
MCMC belongs to the sampling approach to Bayesian inference. Variational inference instead chooses a tractable distribution and optimizes its fit to the posterior. Sampling can apply to a broad range of problems, including those without convenient conjugate priors; variational inference is often faster on small to medium problems and has a more straightforward stopping decision. section 1.4.1 section 4.3

