🌀 Hamiltonian Monte Carlo: Leapfrog Energy Error, Acceptance and Effective Sample Size
Sample a correlated Gaussian, a twisted banana or a two-mode target with Hamiltonian Monte Carlo and watch a steel ball roll over the landscape of potential energy U = -log(target). Tune the leapfrog step size, number of steps and mass, compare with a random-walk Metropolis sampler, and read the acceptance, energy error, autocorrelation and effective sample size. A Blender-built stone landscape, with numerical checks of reversibility, volume preservation, the step-size stability limit and the exact moments built in.
Fitting a Bayesian model means characterising a posterior distribution that almost never has a closed form — so instead you sample from it. This simulator renders that posterior as a real 3D probability-density surface and runs Hamiltonian Monte Carlo on it exactly as Stan or PyMC would: each proposal samples a random momentum, integrates a physical trajectory across the surface with the leapfrog method, and accepts or rejects it by how well total energy was conserved. Watch the chain glide along a correlated ridge far more efficiently than a naive random walk could, tune the step size and trajectory length to see acceptance rate trade off against exploration, and switch to a bimodal target to see where even a gradient-aware sampler can get stuck in one mode.
Sample a correlated Gaussian, a twisted banana or a two-mode target with Hamiltonian Monte Carlo and watch a steel ball roll over the landscape of potential energy U = -log(target). Tune the leapfrog step size, number of steps and mass, compare with a random-walk Metropolis sampler, and read the acceptance, energy error, autocorrelation and effective sample size. A Blender-built stone landscape, with numerical checks of reversibility, volume preservation, the step-size stability limit and the exact moments built in.
3D · Three.js / WebGL renderer · 60 FPS target · runs fully client-side, no install