Hamiltonian Monte Carlo (HMC) is a Markov chain Monte Carlo sampling algorithm that uses Hamiltonian dynamics to generate distant, low-autocorrelation proposals in high-dimensional parameter spaces. By treating the negative log-posterior as a potential energy and augmenting with auxiliary momentum variables, HMC can traverse the posterior landscape far more efficiently than random-walk Metropolis methods.
Content
- Hamiltonian Monte Carlo was introduced to the statistics community by Radford Neal in his 1994 technical report and popularised through his chapter in the 2011 “Handbook of Markov Chain Monte Carlo”. The method originates in Hybrid Monte Carlo, a technique proposed by Duane et al. in 1987 for lattice quantum chromodynamics simulations in physics. The key insight was that auxiliary momentum variables drawn from a Gaussian distribution, combined with leapfrog integration of Hamilton’s equations of motion, generate proposals that move far along the posterior surface while maintaining detailed balance and thus ergodicity.
- The algorithm augments the parameter vector θ with a momentum vector p drawn fresh at each iteration from a Gaussian. It then simulates L leapfrog steps of size ε, alternating gradient updates on p and position updates on θ. After L steps, the proposed (θ*, p*) pair is accepted or rejected with a Metropolis correction that accounts for numerical integration error. The No-U-Turn Sampler (NUTS), developed by Hoffman and Gelman in 2011, eliminates the need to hand-tune L by dynamically terminating the trajectory when it begins to double back on itself, making HMC practical for non-expert users.
- HMC matters because it scales gracefully to hundreds or thousands of parameters — a regime where random-walk Metropolis requires exponentially more samples. This efficiency has made it the backbone of probabilistic programming systems such as Stan, PyMC, and NumPyro. In scientific modelling, HMC enables posterior inference for complex hierarchical models in epidemiology, astrophysics, econometrics, and molecular dynamics, where correctly quantified uncertainty is as important as a point estimate.
- In 2024–2025, HMC development has focused on GPU-accelerated leapfrog integrators (enabling batched parallel chains on modern hardware), Riemannian HMC variants that adapt the mass matrix to local geometry for highly curved posteriors, and integration with automatic differentiation frameworks such as JAX and PyTorch. Normalising flows are being explored as learnable mass-matrix preconditioners. Differentiable probabilistic programming, exemplified by systems like Pyro and Gen, increasingly positions HMC as the gold-standard reference sampler against which variational approximations are validated.