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›Dynamic Hamiltonian Monte Carlo
Bayesian methodsBayesian / computational

Dynamic Hamiltonian Monte Carlo

Dynamic Hamiltonian Monte Carlo (No-U-Turn Sampler) · Also known as: Dynamic HMC, NUTS, No-U-Turn Sampler, adaptive HMC

Dynamic Hamiltonian Monte Carlo — widely known as the No-U-Turn Sampler (NUTS) — is an adaptive extension of Hamiltonian Monte Carlo that automatically selects the number of leapfrog integration steps during each MCMC transition, removing the need to hand-tune the most sensitive tuning parameter of standard HMC. It is the default sampler in Stan and PyMC and is suitable for continuous, differentiable posterior distributions of moderate to high dimension.

ScholarGate
  1. Bayesian methods
  2. v1
  3. 2 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.

Dynamic Hamiltonian Monte Carlo
Bayesian RegressionGibbs SamplingHamiltonian Monte CarloSequential Monte CarloVariational Inference

When to use it

Use Dynamic HMC when the posterior is continuous and the log-posterior and its gradients are available (as in most Bayesian regression, hierarchical, and latent-variable models). It is especially powerful in moderate to high dimensions (tens to hundreds of parameters) where random-walk samplers like Metropolis-Hastings mix extremely slowly. Do not use it when parameters are discrete (use Gibbs sampling or marginalisation instead), when the log-posterior is not differentiable, or when gradient evaluation is prohibitively expensive — in those cases variational inference or SMC may be preferable.

Strengths & limitations

Strengths
  • Eliminates manual tuning of trajectory length, the most sensitive HMC parameter.
  • Mixes rapidly in high-dimensional, correlated posteriors compared with random-walk methods.
  • Provides strong theoretical guarantees: preserves detailed balance and targets the exact posterior.
  • Produces high effective sample sizes per gradient evaluation in well-conditioned problems.
  • Diagnostic failures (divergences, low E-BFMI, high R-hat) are informative and guide model improvement.
Limitations
  • Requires continuous, differentiable parameters — discrete parameters must be marginalised or handled separately.
  • Gradient computation can be expensive for large datasets or highly complex models.
  • Highly non-linear or funnel-shaped posteriors can cause divergent transitions even with optimal tuning.
  • Warm-up phase requires many gradient evaluations; short chains may not adapt adequately.

Frequently asked

What is a divergent transition and why does it matter?

A divergent transition occurs when the leapfrog integrator becomes numerically unstable, usually because the posterior has a region of very high curvature (e.g., a funnel). Divergences indicate that samples from that region are unreliable. The correct response is to reparameterise the model (e.g., use a non-centred parameterisation for hierarchical models), not simply to increase the target acceptance rate.

How does NUTS differ from standard HMC?

Standard HMC requires the user to specify both a step size and a fixed number of leapfrog steps (trajectory length). NUTS retains the step size (adapted automatically) but replaces the fixed trajectory length with the U-turn criterion, which dynamically and automatically determines when to stop integrating. This makes NUTS dramatically easier to use and often more efficient.

What is the mass matrix and why does it matter?

The mass matrix M in the Hamiltonian controls how the algorithm moves through parameter space. A diagonal mass matrix set to the inverse marginal variances of the posterior rescales each dimension so they are on a similar scale, improving mixing. A dense mass matrix can also capture correlations. Poor mass-matrix estimation leads to slow mixing or step-size collapse.

Can I use Dynamic HMC with discrete parameters?

Not directly. Leapfrog integration requires continuous, differentiable parameters. Discrete parameters must be marginalised analytically, assigned to a Gibbs step, or handled with methods such as embedding discrete variables in a continuous relaxation. Stan requires all parameters to be continuous for this reason.

How many warm-up and sampling iterations do I need?

A common starting point is 1000 warm-up and 1000 sampling iterations per chain with 4 chains. For complex posteriors, 2000 warm-up iterations improve mass-matrix estimation. Adequacy is judged by R-hat (below 1.01) and bulk/tail effective sample sizes (above 100 per chain as a minimum), not by iteration count alone.

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(1), 1593–1623. link ↗
  2. Neal, R. M. (2011). MCMC using Hamiltonian dynamics. In S. Brooks, A. Gelman, G. Jones & X.-L. Meng (Eds.), Handbook of Markov Chain Monte Carlo (pp. 113–162). CRC Press. ISBN: 978-1420079418

How to cite this page

ScholarGate. (2026, June 3). Dynamic Hamiltonian Monte Carlo (No-U-Turn Sampler). ScholarGate. https://scholargate.app/en/bayesian/dynamic-hamiltonian-monte-carlo

Related methods

Bayesian RegressionGibbs SamplingHamiltonian Monte CarloSequential Monte CarloVariational 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
  • Gibbs SamplingBayesian↔ compare
  • Hamiltonian Monte CarloBayesian↔ compare
  • Sequential Monte CarloBayesian↔ compare
  • Variational InferenceBayesian↔ compare
Compare side by side →

Similar methods

No-U-Turn SamplerHamiltonian Monte CarloHierarchical Hamiltonian Monte CarloRobust Hamiltonian Monte CarloHamiltonian Monte Carlo with Missing DataMarkov Chain Monte CarloMultilevel Hamiltonian Monte CarloMetropolis-Hastings Algorithm

Related reference concepts

Hamiltonian Monte CarloBayesian Computation and MCMCMetropolis-Hastings AlgorithmMarkov Chain Monte CarloMarkov Chain Monte CarloGibbs Sampling

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

ScholarGate — Dynamic Hamiltonian Monte Carlo (Dynamic Hamiltonian Monte Carlo (No-U-Turn Sampler)). Retrieved 2026-07-21 from https://scholargate.app/en/bayesian/dynamic-hamiltonian-monte-carlo · Dataset: https://doi.org/10.5281/zenodo.20539026
Quick facts
Originator
Matthew D. Hoffman and Andrew Gelman
Year
2014
Type
adaptive MCMC sampler
DataType
continuous parameters; any model with differentiable log-posterior
Subfamily
Bayesian / computational
Related methods
Bayesian RegressionGibbs SamplingHamiltonian Monte CarloSequential Monte CarloVariational 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