Math 2.0

Numerical analysis Monte Carlo and quasi-Monte Carlo methods Proposition

Hamiltonian Monte Carlo

Builds on Markov chain Monte CarloProbability density functionMultivariate normal distributionGradientStationary distributionDetailed balanceHamiltonian systemSymplectic integratorInvolutionMetropolis–Hastings algorithm

Statement

Let U ⁣:ℝd→ℝU \colon \R^d \to \R be continuously differentiable with Z=∫ℝde−U(q) dq<∞Z = \int_{\R^d} e^{-U(q)} \, dq < \infty, and let π\pi be the probability density π(q)=e−U(q)/Z\pi(q) = e^{-U(q)} / Z. Let H(q,p)=U(q)+12∣p∣2H(q,p) = U(q) + \tfrac{1}{2} \abs{p}^2 for q,p∈ℝdq, p \in \R^d. Fix a step size ε>0\varepsilon > 0 and a number of steps L≥1L \ge 1. The leapfrog step Ψ(q,p)=(q′,p′)\Psi(q,p) = (q', p') is p1/2=p−ε2∇U(q),q′=q+ε p1/2,p′=p1/2−ε2∇U(q′),p_{1/2} = p - \tfrac{\varepsilon}{2} \nabla U(q), \qquad q' = q + \varepsilon \, p_{1/2}, \qquad p' = p_{1/2} - \tfrac{\varepsilon}{2} \nabla U(q'), where ∇U\nabla U is the gradient of UU, and Φ=ΨL\Phi = \Psi^{L} is LL leapfrog steps. One Hamiltonian Monte Carlo step from q∈ℝdq \in \R^d is as follows.

  1. Draw pp from the standard normal distribution on ℝd\R^d.
  2. Compute (q∗,p∗)=Φ(q,p)(q^*, p^*) = \Phi(q, p).
  3. With probability min⁡(1,eH(q,p)−H(q∗,p∗))\min\big(1, e^{H(q,p) - H(q^*, p^*)}\big) move to q∗q^*; otherwise stay at qq.

Then π\pi is a stationary distribution of this Markov transition: if qq has density π\pi, the new state also has density π\pi.

Remarks

The proof works on the joint density proportional to e−H(q,p)e^{-H(q,p)} on ℝ2d\R^{2d}, whose qq-marginal is π\pi and whose pp-marginal is standard normal. Let R(q,p)=(q,−p)R(q,p) = (q,-p); then F=R∘ΦF = R \circ \Phi is an involution, since each leapfrog step is reversed by flipping the momentum, and FF preserves volume, since each of the three substeps is a shear. A Metropolis step with a deterministic, volume-preserving, involutive proposal FF and acceptance probability min⁡(1,eH−H∘F)\min(1, e^{H - H \circ F}) satisfies detailed balance for e−He^{-H}, and H∘R=HH \circ R = H. Resampling pp in step 1 also leaves e−He^{-H} invariant, so the composition does, and hence its qq-marginal π\pi is invariant. The leapfrog map is a symplectic integrator for the Hamiltonian system q˙=p\dot q = p, p˙=−∇U(q)\dot p = -\nabla U(q). The exact flow would keep HH constant and always accept, and the accept step corrects the discretisation error. Example: for U(q)=12q2U(q) = \tfrac{1}{2} q^2 on ℝ\R, the target is standard normal, and with small ε\varepsilon the trajectories follow circles in the (q,p)(q,p) plane, so the chain moves far in each step. Invariance alone does not give convergence. For this UU, if εL\varepsilon L is half a period of the exact flow, the chain nearly alternates between qq and −q-q. For this reason ε\varepsilon or LL is often randomised in practice. More generally pp may be drawn from a normal law with a positive definite mass matrix MM, with 12pTM−1p\tfrac{1}{2} p^T M^{-1} p in HH and q′=q+εM−1p1/2q' = q + \varepsilon M^{-1} p_{1/2}.

Going deeper

For a student

HMC is a Markov chain Monte Carlo method that uses the gradient of the log-density to make long, directed moves. It is a special case of the Metropolis–Hastings algorithm on the extended space of positions and momenta. The two properties of the leapfrog map that make the acceptance rule simple are reversibility and volume preservation; energy conservation is only needed for a high acceptance rate. Compared with random-walk proposals, HMC scales much better with dimension for smooth targets, which is why it is the default sampler in several statistics packages. Choosing ε\varepsilon and LL is the main practical difficulty, and adaptive schemes such as the no-U-turn sampler address it.

Reading path

To understand this page from the ground up, read these 17 pages in order. The foundations come first.

Show the path as a graph
Each page uses the pages above it. The colour of the bar on a box shows how strong the evidence is, and the box also gives it as text. The list has the same pages.
  • no evidence level
  1. Detailed balance concept
  2. Euclidean space object
  3. Function concept
  4. Hamiltonian system concept
  5. Involution concept
  6. Markov chain Monte Carlo concept
  7. Metropolis–Hastings algorithm concept
  8. Multivariate normal distribution concept
  9. Probability density function concept
  10. Stationary distribution concept
  11. Symplectic integrator concept
  12. Total derivative concept
  13. Function of several variables concept
  14. Differentiable function of several variables concept
  15. Partial derivative concept
  16. Gradient concept
  17. Hamiltonian Monte Carlo statement

Further reading

  1. Web https://en.wikipedia.org/wiki/Hamiltonian_Monte_Carlo
About this page
Tag4AHBMJYCX1
URIm2://4AHBMJYCX1
Kindstatement, proposition
WritingW0 stub
MSC65C05, 65C40, 60J22
StatusThis copy of the site has no build data. Run m2 status 4AHBMJYCX1.
AboutMarkov chain Monte Carlo
UsesMarkov chain Monte Carlo, Probability density function, Multivariate normal distribution, Gradient, Stationary distribution, Detailed balance, Hamiltonian system, Symplectic integrator, Involution, Metropolis–Hastings algorithm
Same as

Markdown · JSON · Edit on GitHub

What this page needs for W1

  • an inventory row: the row of the inventory that the node accounts for (0 of 1)
  • a source with a locator (0 of 1)

The writing levels say how complete the text of a page is. They do not measure its truth.

What links here

No page links to this page yet.