Interactive demo · Probabilistic Machine Learning: Advanced Topics · Chapter 12

Hamiltonian Monte Carlo: how the leapfrog step size and the geometry decide

Each iteration draws a fresh momentum v ~ N(0, I), follows the Hamiltonian dynamics for L leapfrog steps of size η and accepts the end point with probability min(1, e−ΔH). On a Gaussian the leapfrog map is stable only when η is below twice the smallest standard deviation; in Neal's funnel the required step size shrinks exponentially down the neck, so a fixed step either diverges there or never gets there, unless the model is reparameterised.

Target

Sampler

Leapfrog step η (log scale)

Leapfrog steps L

Proposal scale τ (log scale)

Iterations

Try these

Unit mass matrix. A trajectory whose energy error exceeds 1000 (or overflows) is a divergence and is rejected. Gaussian: correlation 0.95, unit variances, so the smallest standard deviation is √0.05 = 0.224. Funnel: ν ~ N(0, 32), x | ν ~ N(0, eν); the non-centred version samples (z, ν) with x = z eν/2 and is drawn in (x, ν). Cars: binomial logistic regression of poor fuel economy on weight (Figure 12.8), N(0, 202) priors. The effective sample size is (12.110) for one chain.

In the lecture notes