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.
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.
code/ch12_mcmc.py (leapfrog, hmc, funnel_logp, car_logpost, demo_hmc_run); data data/ch12-cars.json; Figures 12.8, 12.18 and 12.S3 in the code index.