Skip to contentScholarGate
LibraryBookshelfDeskReview StudioAssistant
Sign in
On this page
IntuitionHow it worksWhen to use itStrengths & limitationsCommon pitfallsApplicationsFrequently asked🔒 Read the full methodSourcesRelated methods
Cite this pageSpotted an issue on this page? Report or suggest a fix →
Home›Bayesian›No-U-Turn Sampler (NUTS)
Bayesian methods

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.

ScholarGate
  1. Bayesian methods
  2. v1
  3. 3 Sources
  4. PUBLISHED
Cite this page →
Tools & resources
Download slides
Learn & explore

Read the full method

Members only

Sign in with a free account to read this section.

Sign in

Method map

The neighbourhood of related methods — select a node to explore.

No-U-Turn Sampler
Bayesian RegressionHamiltonian Monte CarloMCMCVariational Inference

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

Strengths
  • 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.
Limitations
  • 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

  1. 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 ↗
  2. 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 ↗
  3. 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

Related methods

Bayesian RegressionHamiltonian Monte CarloMCMCVariational Inference

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
Compare side by side →

Similar methods

Dynamic Hamiltonian Monte CarloHamiltonian Monte CarloHierarchical Hamiltonian Monte CarloRobust Hamiltonian Monte CarloMarkov Chain Monte CarloHamiltonian Monte Carlo with Missing DataMCMCAutomatic Differentiation Variational Inference

Related reference concepts

Hamiltonian Monte CarloBayesian Computation and MCMCMarkov Chain Monte CarloMetropolis-Hastings AlgorithmMarkov Chain Monte CarloGibbs Sampling

Spotted an issue on this page? Report or suggest a fix →

ScholarGate — No-U-Turn Sampler (No-U-Turn Sampler (NUTS)). Retrieved 2026-07-21 from https://scholargate.app/en/bayesian/no-u-turn-sampler · Dataset: https://doi.org/10.5281/zenodo.20539026
Quick facts
Family
Bayesian / MCMC
Type
Sampling algorithm (MCMC)
Originator
Matthew D. Hoffman & Andrew Gelman
Year
2014
Purpose
Draw samples from posterior distributions without manual tuning of trajectory length
Tuning
Dual averaging (step size) + No-U-Turn criterion (trajectory length)
Default Sampler In
Stan, PyMC
Outputs
Posterior samples, R-hat, ESS, energy diagnostics
Related methods
Bayesian RegressionHamiltonian Monte CarloMCMCVariational Inference
ScholarGate

A content-first reference library for research methods — what each one is, how it works, and where it comes from.

Open data (CC-BY)

Explore

  • Library
  • Search the library…
  • Browse by field
  • Fields
  • Journey
  • Compare
  • Which method?

Reference

  • Subjects
  • Atlas
  • Glossary
  • Methodology
  • Philosophy

Your tools

  • Bookshelf
  • Desk
  • Chat

Company

  • About
  • Pricing
  • Contact
  • Suggest a method

Entries are compiled from published sources for reference. Verifying the accuracy and suitability of any information for your own use remains your responsibility.

© 2026 ScholarGate · A research-method reference library
  • Privacy
  • Cookies
  • Terms
  • Delete account