
Markov chain sampling that uses gradients of the posterior to take long, well-aimed steps in many dimensions.Hamiltonian Monte Carlo (HMC) is a Markov chain Monte Carlo (MCMC) method for sampling from probability distributions, particularly those with many dimensions. Unlike simpler random-walk methods, HMC uses the gradient of the target distribution to propose moves that are far away from the current point, while still maintaining a high acceptance rate. This makes it highly efficient for exploring high-dimensional spaces, where random walks tend to wander slowly. HMC is a cornerstone of modern Bayesian computation, especially in fields like machine learning and statistical physics.
The method was introduced by Simon Duane, Anthony Kennedy, Brian Pendleton, and Duncan Roweth in 1987, building on earlier work in lattice gauge theory.
HMC interprets the target distribution as a potential energy function and introduces auxiliary 'momentum' variables. The system then evolves according to Hamiltonian dynamics, simulating a frictionless ball rolling on a landscape shaped by the negative log of the target distribution. After a simulated trajectory, the new position and momentum are accepted or rejected using a Metropolis step, which corrects for any discretization error. The key is that the dynamics are reversible and volume-preserving, so the algorithm converges to the correct distribution. The gradient guides the trajectory toward regions of high probability, allowing large jumps.
It is the default sampling algorithm in probabilistic programming languages like Stan and PyMC, used for fitting complex Bayesian models in social science, biology, and finance.
The 'Hamiltonian' in the name refers to William Rowan Hamilton's reformulation of classical mechanics, which the algorithm borrows to turn sampling into a physics simulation.











