Come analyze HEASARC, IRSA, and MAST data in the cloud! The Fornax Initiative is now welcoming all interested beta users.
Hamiltonian Monte Carlo (hmc)
Hamiltonian Monte Carlo (HMC) treats the negative log posterior as a potential energy, augments the parameter space with auxiliary momenta, and integrates Hamilton's equations to propose long-range moves that are accepted with very high probability. XSPEC's implementation uses the No-U-Turn Sampler (NUTS) variant, which removes the need to tune the integration length, together with a warm-up phase that adapts the step size and a diagonal mass matrix.
HMC requires the gradient of the log posterior with respect to every free parameter. XSPEC computes this analytically for models that have registered gradient implementations (the majority of additive, multiplicative, and convolution models that ship with XSPEC) and falls back to finite differences for the remainder. Some classes of models — notably the OGIP table models and several legacy Fortran routines — still use the finite-difference path.
Strengths. HMC scales much better than MH or GW into
high dimensions, where the latter's per-step efficiency falls
exponentially. On smooth posteriors with
parameters
HMC often produces an effective sample per few likelihood evaluations,
whereas MH may need hundreds. Multiple chains can be run in parallel
via parallel hmc; the implementation forks chains rather
than walkers, so the speedup is close to linear with cores until the
chains start sharing memory bandwidth.
Weaknesses. The per-leapfrog-step cost is one gradient
evaluation, which for analytically supported models costs about as
much as one likelihood, but for finite-difference fallbacks costs
likelihoods. A single NUTS step takes 8–32 leapfrog steps on
typical X-ray spectra, so HMC's per-sample cost can be 100–1000
times that of MH if many parameters fall back to finite differences.
HMC is also unforgiving of pathological geometry: posteriors with
funnels, ridges, or near-zero-volume modes will produce divergences
that show up in the output as warnings.
Tips. Warm up generously; a thousand warm-up samples
(hmc warmup) is a sensible default. Watch the per-chain
divergence count printed at the end of the run; if it exceeds a few
percent of the total samples the step size adapted too aggressively
and the parameterization should be reconsidered. Use
hmc target_accept 0.9 if divergences persist (the
default is ). For multi-modal posteriors HMC will get trapped
in whichever mode the warm-up converged into; this is by design and
must be addressed with a different sampler or with explicit tempering.