No-U-Turn Sampler: Adaptive HMC Trajectory Doubling
Watch the No-U-Turn Sampler (NUTS) draw from a curved Bayesian posterior in 3D: a binary tree of leapfrog steps doubles forward and backward until the trajectory starts to turn back on itself, then a sample is chosen automatically — no hand-tuned step count.
The No-U-Turn Sampler (NUTS) is the algorithm quietly doing the heavy lifting inside Stan, PyMC and NumPyro every time a real Bayesian model gets fit. This simulator renders a curved, "banana-shaped" 2D posterior as a 3D probability surface and runs the actual NUTS mechanism on it: each draw resamples momentum, then grows a binary tree of leapfrog integration steps — doubling forward or backward at random — until the no-U-turn criterion (θ⁺−θ⁻)·r ≥ 0 fails at both ends, at which point a sample is chosen automatically from the states visited. Watch the leapfrog tree trace the curving ridge, adjust the step size and maximum tree depth, and run Auto-Sample to see the accumulated draws reconstruct the posterior's true bent shape — exactly the geometry that breaks naive random-walk Metropolis but NUTS handles without any hand-tuned trajectory length.
Watch the No-U-Turn Sampler draw from a curved Bayesian posterior in 3D: a binary tree of leapfrog steps doubles forward and backward automatically until the trajectory would start turning back on itself, then a sample is chosen.
3D · Three.js / WebGL renderer · 60 FPS target · runs fully client-side, no install