HomeAI & Machine LearningHamiltonian Monte Carlo: Leapfrog Sampling

Hamiltonian Monte Carlo: Leapfrog Sampling

Watch Hamiltonian Monte Carlo sample a Bayesian posterior in 3D: a momentum-augmented particle rolls across a probability-density surface via leapfrog integration, with live accept/reject decisions and acceptance-rate tracking.

AI & Machine Learning3DAdvanced60 FPS📱 Mobile-adapted⇄ 2D version
bayesian-inference-mcmc-sampling ↗ Open standalone

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.

⚙ Under the hood

Watch Hamiltonian Monte Carlo sample a Bayesian posterior in 3D: a momentum-augmented particle rolls across a probability-density surface via leapfrog integration, with live accept/reject decisions and acceptance-rate tracking.

bayesian inferencemcmchamiltonian monte carloleapfrog integrationposterior samplingmachine learning

3D · Three.js / WebGL renderer · 60 FPS target · runs fully client-side, no install

What did you find?

Add reproduction steps (optional)