Markov chain Monte Carlo: sampling the hard-to-calculate
Markov chain Monte Carlo is a family of computational methods that explore a complicated probability distribution by taking a guided random walk through it.
What it is
Markov chain Monte Carlo, usually shortened to MCMC, is a family of computational methods for drawing samples from a probability distribution that is too complicated to calculate directly. It works by building a random walk whose long-run behaviour settles into the target distribution, so that the points the walk visits can be treated as a representative sample from it.
The name joins two ideas. A Markov chain is a sequence of random steps in which each step depends only on the current position, not on the path taken to reach it. Monte Carlo refers to the general practice of estimating quantities by repeated random sampling. In a typical MCMC algorithm, the walk proposes a move to a new point and then accepts or rejects it according to a rule that compares how probable the new and old points are. Well-known versions include the Metropolis–Hastings algorithm, Gibbs sampling and Hamiltonian Monte Carlo, which uses the slope of the distribution to make longer, better-directed moves.
The methods matter most in Bayesian statistics, where conclusions about unknown quantities are expressed as a posterior distribution. Calculating that distribution exactly usually requires integrals over many dimensions that cannot be solved. MCMC needs only to compare relative probabilities between points, which is far easier. The price is that successive samples are correlated, the early part of a run often has to be discarded, and the user must judge whether the chain has run long enough to represent the distribution faithfully.
What research is finding
Some published work on MCMC describes software that makes the methods usable at scale, with several examples from evolutionary biology. A software announcement for MrBayes 3.2, a package for Bayesian inference of evolutionary trees, reports added convergence diagnostics, parallel runs monitored as they progress, and new proposals with automatic tuning that improved convergence for many problems[1]. The same paper reports faster likelihood calculations, with speed-ups ranging from around two with one set of processor instructions to more than fifty with the BEAGLE library for codon problems, a library that allows calculations to be delegated to graphics processors on compatible hardware[1]. Another package, BEAST 1.7, is described as implementing a family of MCMC algorithms for Bayesian phylogenetic inference, dating divergences between lineages, coalescent analysis and tracing the geography of evolution[4]. Because MCMC output is a long list of samples, interpreting it is a task in itself; a software paper on Tracer 1.7 presents tools for visualising and analysing these traces, calling that step key to any non-trivial Bayesian inference[3].
Other work targets the sampling algorithm itself. A software paper from astronomy introduces emcee, a Python implementation of an affine-invariant ensemble sampler[2]. Its authors report that it needs hand-tuning of only one or two parameters, compared with roughly the square of the number of dimensions for a traditional algorithm, and that it can use multiple processor cores without extra effort[2]. The Stan probabilistic programming language, described in a software paper, offers full Bayesian inference for models with continuous variables through MCMC methods such as an adaptive form of Hamiltonian Monte Carlo, and it can also compute log densities and their gradients[5].
MCMC also has competitors. A review of variational inference, which approximates a distribution by optimisation rather than sampling, states that this approach tends to be faster than classical methods such as MCMC[6].
Open questions
The central practical difficulty is knowing when a chain has done its job. A finite run can never prove that it has explored the whole distribution, and diagnostics can flag likely problems without guaranteeing success. Distributions with several separated peaks, or with very many dimensions, remain especially hard, and how best to tune proposals for such cases is still an active area.
There is also an unsettled trade-off between accuracy and speed. Sampling methods are generally regarded as reliable given enough computing time, while faster approximations give up some of that assurance. The review of variational inference describes the method as powerful but not yet well understood, and highlights important open problems[6]. How to choose between these approaches, or combine them, for a given problem is likely to remain a live question.
Papers
- MrBayes 3.2: Efficient Bayesian Phylogenetic Inference and Model Choice Across a Large Model Space. Systematic Biology, 2012. doi:10.1093/sysbio/sys029
- emcee : The MCMC Hammer. Publications of the Astronomical Society of the Pacific, 2013. doi:10.1086/670067
- Posterior Summarization in Bayesian Phylogenetics Using Tracer 1.7. Systematic Biology, 2018. doi:10.1093/sysbio/syy032
- Bayesian Phylogenetics with BEAUti and the BEAST 1.7. Molecular Biology and Evolution, 2012. doi:10.1093/molbev/mss075
- Stan : A Probabilistic Programming Language. Journal of Statistical Software, 2017. doi:10.18637/jss.v076.i01
- Variational Inference: A Review for Statisticians. Journal of the American Statistical Association, 2017. doi:10.1080/01621459.2017.1285773