No-U-Turn Sampler (NUTS)
Also known as: NUTS, No-U-Turn HMC, adaptive Hamiltonian Monte Carlo, self-tuning HMC
The No-U-Turn Sampler (NUTS) is a self-tuning Markov chain Monte Carlo algorithm introduced by Hoffman and Gelman (2014) that extends Hamiltonian Monte Carlo (HMC) by automatically determining the optimal number of leapfrog steps, eliminating the most sensitive manual tuning parameter. NUTS is the default sampler in Stan and PyMC and has made large-scale, high-dimensional Bayesian inference practically accessible without requiring users to set trajectory lengths by hand.
Read the full method
Sign in with a free account to read this section.
Method map
The neighbourhood of related methods — select a node to explore.
When to use it
NUTS is the default choice for posterior sampling in most Bayesian models when the posterior is continuous and gradients of the log-posterior with respect to the parameters are available. It performs best for medium to large parameter spaces (tens to thousands of dimensions) where random-walk Metropolis-Hastings mixes extremely slowly. It is appropriate when the model is coded in Stan or PyMC (which compute gradients automatically via automatic differentiation), or when the user can supply analytical or AD-based gradients in a custom implementation. NUTS is not directly applicable to discrete parameter spaces (discrete parameters must be marginalized out or handled by separate samplers), nor to very cheap likelihoods where simpler samplers are adequate.
Strengths & limitations
- Eliminates the most sensitive HMC tuning parameter (trajectory length L) through the automatic No-U-Turn stopping criterion.
- Self-tunes the leapfrog step size during warm-up via dual averaging, requiring no manual calibration.
- Mixes far faster than random-walk Metropolis in high-dimensional and correlated posteriors, yielding many more effective samples per gradient evaluation.
- Ships as the default, production-grade sampler in Stan and PyMC, giving access to a mature ecosystem of diagnostics (R-hat, ESS, energy fraction of missing information).
- Scales to hundreds or thousands of parameters, making it practical for hierarchical and latent-variable models that are intractable with simpler MCMC.
- Requires continuous, differentiable log-posterior; discrete parameters cannot be sampled directly and must be marginalized or handled separately.
- Each leapfrog step evaluates the full gradient of the log-posterior, making each iteration more expensive than a Metropolis step — the payoff is higher effective sample size per unit time, but this trade-off can be unfavorable for very cheap likelihoods.
- Warm-up (typically 500–1000 iterations) is needed for step-size adaptation; the adapted parameters are discarded before collecting posterior samples.
- Posterior geometry with very sharp curvature changes (funnel-like hierarchical models) can still challenge NUTS; reparameterisation (e.g. non-centred parameterisation) is often required.
- Diagnosing failures requires understanding energy diagnostics and divergent transitions, which adds an interpretive burden compared to simpler samplers.
Frequently asked
What is the difference between NUTS and plain Hamiltonian Monte Carlo?
Standard HMC requires the user to specify two parameters: the leapfrog step size ε and the number of leapfrog steps L. Choosing L poorly leads either to slow mixing (too small) or wasted computation when the trajectory doubles back (too large). NUTS replaces the fixed L with the No-U-Turn stopping criterion — it doubles the trajectory until it detects a U-turn and then selects a point from the resulting tree — so L is set automatically. Step size is handled by dual averaging during warm-up. The result is that NUTS reproduces the performance of well-tuned HMC without requiring the user to tune L at all.
What are divergent transitions and why do they matter?
A divergent transition occurs when the leapfrog integrator encounters a region of the posterior with very high curvature and the simulated Hamiltonian deviates substantially from its initial value. This signals that the sampler has explored a region it cannot integrate accurately, and the resulting samples from that region are biased. In Stan and PyMC, divergences are flagged explicitly. Even a small number of divergences (say, more than about 0.1% of post-warm-up iterations) warrants investigation. The remedy is typically reparameterisation of the model (e.g. switching from a centred to a non-centred parameterisation for hierarchical models) or increasing the target acceptance rate (which reduces the step size and improves integration accuracy).
How should I assess NUTS convergence?
Run at least four chains from dispersed starting values and check: (1) R-hat < 1.01 for all parameters — values above this indicate the chains have not converged to a common distribution; (2) bulk and tail effective sample size (ESS) — aim for at least 100 per chain (400 total) for reliable posterior summaries and at least 400 for stable tail quantiles; (3) the number of divergent transitions should be near zero after reparameterisation; (4) energy diagnostic (E-BFMI) should be above roughly 0.2; (5) trace plots should show good mixing with no trends or stuck regions.
Can NUTS sample discrete parameters?
No — NUTS requires gradients of the log-posterior with respect to the parameters, which are undefined for discrete quantities. Models with discrete parameters must either marginalize those parameters out analytically (as Stan requires) or handle them with a separate sampler. PyMC supports some compound samplers that pair NUTS for continuous parameters with Metropolis-Hastings steps for discrete ones, but the joint mixing can be slow when the discrete and continuous parameters are highly dependent.
Sources
- Hoffman, M. D., & Gelman, A. (2014). The No-U-Turn Sampler: Adaptively setting path lengths in Hamiltonian Monte Carlo. Journal of Machine Learning Research, 15(47), 1593–1623. link ↗
- Neal, R. M. (2011). MCMC using Hamiltonian dynamics. In S. Brooks, A. Gelman, G. L. Jones, & X.-L. Meng (Eds.), Handbook of Markov Chain Monte Carlo (pp. 113–162). CRC Press. DOI: 10.1201/b10905-6 ↗
- Gelman, A., Carlin, J. B., Stern, H. S., Dunson, D. B., Vehtari, A., & Rubin, D. B. (2013). Bayesian Data Analysis (3rd ed.). CRC Press. ISBN: 978-1-4398-4095-5
How to cite this page
ScholarGate. (2026, June 3). No-U-Turn Sampler (NUTS). ScholarGate. https://scholargate.app/en/bayesian/no-u-turn-sampler
Which method?
Set this method beside its closest kin and read them side by side — the library lays the books on the table; the choice is yours.
- Bayesian RegressionBayesian↔ compare
- Hamiltonian Monte CarloBayesian↔ compare
- MCMCBayesian↔ compare
- Variational InferenceBayesian↔ compare