MCMC and Hamiltonian Monte Carlo
When posteriors have no closed form, the stack samples them; Hamiltonian Monte Carlo makes high-dimensional fusion inference tractable.
Sampling a posterior
Most posteriors over profiles and model parameters cannot be written down, but they can be sampled. Markov chain Monte Carlo (MCMC) builds a chain whose stationary distribution is the posterior; averaging over samples yields any expectation, credible interval, or marginal. This is the stack's gold-standard uncertainty quantification for offline analysis and calibration.
Metropolis-Hastings step:
propose theta' ~ q(theta'|theta)
accept with prob a = min(1, [p(theta'|D) q(theta|theta')] /
[p(theta|D) q(theta'|theta)] )
Hamiltonian Monte Carlo introduces momentum p:
H(theta,p) = -log p(theta|D) + (1/2) p' M^-1 p
simulate Hamiltonian dynamics (leapfrog) -> distant, accepted moves
Why HMC for high dimensions
Random-walk MCMC mixes poorly when parameters are many and correlated - as profile coefficients are. Hamiltonian Monte Carlo uses gradients of the log-posterior (available by autodiff through the twin models) to propose distant, high-acceptance moves, exploring the posterior far more efficiently. The No-U-Turn variant removes manual step tuning.
# leapfrog integrator at the heart of HMC (schematic)
def leapfrog(theta, p, eps, grad_logpost, M_inv):
p = p + 0.5*eps*grad_logpost(theta)
theta = theta + eps*(M_inv @ p)
p = p + 0.5*eps*grad_logpost(theta)
return theta, p # proposes a far state along an energy contour
Diagnostics and honest use
Samples are only trustworthy if the chains converged. The stack checks the potential-scale-reduction R-hat across multiple chains, the effective sample size, and divergence counts. Reported credible intervals come only from converged, well-mixed chains. For the burner, wide priors plus scarce constraints yield deliberately broad posteriors - a faithful picture of an untested regime, not a defect to be tuned away.
- MCMC: samples any posterior, no closed form needed.
- HMC/NUTS: gradient-guided, efficient in high dimensions.
- Convergence checks: R-hat, effective sample size, divergences.
- Broad burner posteriors are honest, not fixed by re-tuning.
MCMC is too slow for the control loop, so it runs offline to calibrate priors and validate the fast variational and ensemble estimators that operate in real time - the rigorous reference behind the quick methods.