/ concept-collection / walnuts-interactive
Sign in
concept-collection / walnuts-interactive
walnuts-interactive / README.md
2.9 KBPreviewCodeBlameHistoryRaw

Interactive WALNUTS sampling#

Runs in the browser via numbl — no install.

Open walnuts_demo.m and click Run#

Samples are drawn from a 2D target by WALNUTS (the within-orbit adaptive leapfrog No-U-Turn Sampler). The figure shows the target density as a heatmap with the samples scattered on top. Switch between several targets (banana, Gaussian, correlated Gaussian, donut) to see the sampler handle different geometries.

WALNUTS is a NUTS variant that grows a Hamiltonian orbit by NUTS-style doubling until a U-turn, but within each step it refines the leapfrog step size — halving the step (and doubling the count) until the energy variation over the step is within a tolerance δ — then picks a draw from the orbit.

Controls:

How it works#

The script sends the density grid + samples via uihtml(..., 'Data', ...). The controls call back: resample re-runs the chain, setTarget switches the target (and rebuilds the density), and movie records a few transitions' orbits; the script replies with sendEventToHTMLSource.

Credits#

Deploy#

Pushing to main builds the app and publishes the project to GitHub Pages via the deploy workflow.

moveopenescclose