Hoffman 2021 - Gaussian Autocorrelation Analysis and Trajectory Jitter

Summary

For HMC on a Gaussian with exact dynamics, first-order autocorrelation is , which cannot be small in all directions for any fixed . Uniform jitter turns cosines into sincs. The second-moment autocorrelation is , minimised near ; using bounds the worst-case first- and second-moment autocorrelations at 0.346 and 0.564.

Overview

The paper builds intuition on a -dimensional zero-mean Gaussian with diagonal covariance , assuming is small enough that leapfrog exact Hamiltonian dynamics. This case matters because “a sampler can hardly be called general-purpose if it fails on multivariate Gaussians” and, via the Bayesian central limit theorem, approximately Gaussian posteriors are common.

Main Content

Phase-space representation (eq. 2)

For dimension define the magnitude-angle pair by and , so and . After trajectory length the state is , . This solves Hamilton’s equations: each coordinate rotates in phase space with angular frequency .

At equilibrium (i.e. ), , independent.

First-order autocorrelation of fixed-length HMC (eq. 3)

. Proof sketch. , , and for uniform .

Consequence (resonance). With many dimensions there is almost surely some with , so there is no that gives low autocorrelation in every direction (Neal 2011, sec. 3.2: this can interfere with ergodicity unless the trajectory length is randomised).

Jittered first-moment autocorrelation (eq. 4)

If , the autocorrelation is , which tends to 0 as . Its minimum is about at . If then .

A chain with is anti-correlated, good for first moments. But for nonlinear functionals, e.g. posterior variance, one needs the autocorrelation of (mean , variance at equilibrium).

Second-moment autocorrelation (eqs 5-6)

Fixed : . Uniform jitter on : . This no longer goes to 0 but to , and it decays twice as fast, with a minimum at . Taking gives worst-case first-moment autocorrelation (eq. 4) and worst-case second-moment autocorrelation (eq. 6).

Numerical check of the constants

The minimum of is at ; the minimum of is at ; ; and the largest positive value of beyond is (at ), giving . These reproduce the paper’s 0.129, 0.346 and 0.564 up to rounding.

Figure 2 interpretation

Ten log-spaced scales . Top row: first moment, bottom row: second moment. Left: fixed (cosines with different periods; the worst-case black line is always near 1 somewhere). Right: jittered (sincs converging to a constant). Second moments raise the minimum achievable autocorrelation from to (fixed ) and from about to about (jittered).

Design lessons the paper draws.

  1. To get low-variance estimators of many expectations at different posterior scales, jitter trajectory lengths and use a maximum length of the order of the largest posterior scale.
  2. For small-scale dimensions () the second-moment autocorrelation is at least about whatever you do, so use the shortest, cheapest that gets there: .
  3. Maximising plain ESJD yields trajectories up to twice as long as optimal, because ESJD is fooled by anti-correlated samples that help means but hurt variances. Maximising ESJD of the centred and squared parameters gives the shorter, efficient length. This is the origin of ChEES.
import numpy as np
x = np.linspace(1e-3, 30, 300000)
sinc = np.sin(x)/x                      # jittered first-moment autocorrelation, x = T/sigma
second = 0.5 + 0.5*np.sin(2*x)/(2*x)    # jittered second-moment autocorrelation
print(x[sinc.argmin()], sinc.min())     # ~4.49, -0.217
print(x[second.argmin()], second.min()) # ~2.25, 0.391

Examples

Sampling a Gaussian whose eigenvalues span five orders of magnitude (the paper’s ill-conditioned Gaussian target) exhibits exactly this resonance problem: fixed- HMC is “disastrous” with too little jitter (Hoffman 2021 - Jitter Ablations, Discussion and Many-Chain Practice).

Connections

Hoffman 2021 - HMC Background and the GPU Problem for NUTS sets up leapfrog; Hoffman 2021 - ChEES Criterion and Algorithm 1 turns the “squared, centred ESJD” idea into an adaptive algorithm. Related vault note: Efficient MCMC.

See Also

Hoffman 2021 - ChEES-HMC - Overview, Hoffman 2022 - GHMC and Neal Persistent Slice Sampling