Introduction

This document provides a comprehensive overview of momentum, its relationship to energy, and how these physical concepts are used in the Hamiltonian Monte Carlo (HMC) algorithm—a powerful tool in Bayesian statistics and machine learning.

1. What is Momentum?

The Physics Definition

In physics, momentum (\(p\)) is defined as mass in motion. It is calculated by multiplying an object’s mass by its velocity:

\[p = m \times v\]

  • Mass (\(m\)): How much “stuff” the object contains.
  • Velocity (\(v\)): How fast it’s moving and in what direction.

Because velocity includes direction, momentum is a vector quantity—it has both magnitude and direction.

The Intuition

Two factors determine momentum: mass and speed.

  • A bowling ball rolling at 5 mph has more momentum than a tennis ball at the same speed (more mass → harder to stop).
  • A bullet has high momentum despite its tiny mass because its velocity is extremely high.

Conservation of Momentum

In a closed system (no outside forces), the total momentum before a collision equals the total momentum after. Momentum is never created or destroyed—it is only transferred between objects.

Example: When a moving pool ball hits a stationary one, the first slows down (loses momentum) and the second speeds up (gains exactly that momentum). The total remains constant.

Everyday Meaning

In daily life, “momentum” describes the strength of a continuing movement:

  • “The company is losing momentum.” → Slowing down, harder to push forward.
  • “We’re gaining momentum on this project.” → Building speed and effort.

3. The Hamiltonian: Combining Energy and Momentum

For a simple mechanical system with mass \(m\), the Hamiltonian (total energy) is:

\[H(q,p) = U(q) + \frac{p^2}{2m}\]

Where:

  • \(q\) = position
  • \(p\) = momentum
  • \(U(q)\) = potential energy (depends on position)
  • \(\frac{p^2}{2m}\) = kinetic energy (depends on momentum)

Why \(p^2\)?

In this equation, \(p^2\) simply means \(p \times p\). It appears because:

\[KE = \frac{1}{2}mv^2 = \frac{1}{2}m\left(\frac{p}{m}\right)^2 = \frac{p^2}{2m}\]

By writing kinetic energy this way, we remove velocity and treat position (\(q\)) and momentum (\(p\)) as independent variables—the foundation of Hamiltonian mechanics.

4. How Does This Relate to HMC?

Hamiltonian Monte Carlo (HMC) is a sampling algorithm used in Bayesian statistics. It borrows physics concepts to efficiently explore probability distributions.

The Physics-to-Statistics Translation

Physics Statistics
Position (\(q\)) Parameter to estimate (e.g., population mean)
Momentum (\(p\)) Auxiliary variable (randomly sampled)
Potential energy (\(U(q)\)) Negative log-posterior: \(-\log(\text{Posterior})\)
Kinetic energy (\(\frac{p^2}{2m}\)) Drives exploration of the parameter space

How HMC Works

  1. Inject Random Momentum: At each step, randomly sample \(p\) from a normal distribution. The probability of picking \(p\) is proportional to \(e^{-p^2/2m}\) — a Gaussian (bell curve).

  2. Simulate Motion: Use Hamilton’s equations to move the particle across the \(U(q)\) landscape for a fixed time. The kinetic energy \(\frac{p^2}{2m}\) gives it inertia to keep moving in good directions.

  3. Accept/Reject: Because numerical simulation has errors, check if total energy \(H(q,p)\) was conserved. If yes, accept the new sample; if not, reject it.

Why \(p^2\) Makes HMC Powerful

  • Prevents random wandering: Momentum gives the particle inertia—once it rolls in a good direction, it keeps going.
  • Tunes exploration: The “mass” \(m\) controls behavior:
    • Large \(m\): Heavy particle, moves slowly but explores globally (freight train).
    • Small \(m\): Light particle, moves quickly but bounces locally (bumblebee).

The Acceptance Rule

After simulation, the acceptance probability is:

\[\text{Acceptance} = \min(1, e^{-\Delta H})\]

If the simulation is perfect, \(\Delta H = 0\) and acceptance is 100%—the holy grail of sampling!

5. Why \(U(q) = -\log(\text{Posterior})\)?

This is the critical link between physics and statistics.

The Boltzmann Distribution

In physics, the probability of a state with energy \(E\) is:

\[P(\text{state}) \propto e^{-E}\]

Set \(E = H(q,p) = U(q) + \frac{p^2}{2m}\):

\[P(q,p) \propto e^{-U(q)} \times e^{-p^2/2m}\]

The probabilities separate! The probability of position \(q\) is:

\[P(q) \propto e^{-U(q)}\]

Solving for \(U(q)\)

Take logs:

\[\log(P(q)) = -U(q) \implies U(q) = -\log(P(q))\]

The Intuition

  • High probability → \(-\log(\text{High})\) is small → low potential energy (a valley).
  • Low probability → \(-\log(\text{Low})\) is large → high potential energy (a mountain).

In Bayesian Terms

\[\text{Posterior} \propto \text{Likelihood} \times \text{Prior}\]

So:

\[U(q) = -\log(\text{Likelihood}) - \log(\text{Prior})\]

The particle rolls downhill to high-probability regions (valleys) and rarely climbs up to low-probability regions (mountains). By sampling from this landscape, HMC generates a histogram of \(q\) values that matches the true posterior distribution.

Summary:

  • Momentum (\(p = mv\)) is “mass in motion”—a measure of how hard it is to stop an object.
  • Kinetic energy (\(KE = \frac{1}{2}mv^2 = \frac{p^2}{2m}\)) measures the capacity to do work.
  • The Hamiltonian combines them: \(H = U + \frac{p^2}{2m}\).
  • In HMC, we set \(U(q) = -\log(\text{Posterior})\) to turn probability mountains into physics valleys. The particle explores these valleys, spending most time where probability is highest.
  • The \(p^2\) term provides inertia, allowing HMC to explore efficiently—much faster than random wandering.