θ-space: posterior density & chainPhase space (θ₁, r₁) + energy trace
Live leapfrog trajectory Accepted sample Rejected proposal Energy trace H(t)

Hamiltonian Monte Carlo: Phase-Space Leapfrog (2D)

Fitting a Bayesian model means characterising a posterior distribution that almost never has a closed form — so instead you sample from it. This 2D simulator runs the same Hamiltonian Monte Carlo algorithm as Stan or PyMC — sample a random momentum, integrate a physical trajectory with the leapfrog method, accept or reject by how well total energy was conserved — but renders it as two linked 2D views instead of a rotating 3D terrain: a contour map of the posterior density with the accepted-sample trail, and a genuine phase-space portrait of (θ₁, momentum r₁) with a live energy trace beneath it, so you can watch the leapfrog integrator's near-conservation of H directly instead of inferring it from a rolling ball. 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.