No-U-Turn MCMC Sampler

class pints.NoUTurnMCMC(x0, sigma0=None)[source]

Implements the No U-Turn Sampler (NUTS) with dual averaging, as described in Algorithm 6 in [1].

Implements the multinomial sampling suggested in [2]. Implements a mass matrix for the dynamics, which is detailed in [2]. Both the step size and the mass matrix is adapted using a combination of the dual averaging detailed in [1], and the windowed adaption for the mass matrix and step size implemented in the Stan library (https://github.com/stan-dev/stan).

Like Hamiltonian Monte Carlo, NUTS imagines a particle moving over negative log-posterior (NLP) space to generate proposals. Naturally, the particle tends to move to locations of low NLP – meaning high posterior density. Unlike HMC, NUTS allows the number of steps taken through parameter space to depend on position, allowing local adaptation.

Note: This sampler is only supported on Python versions 3.3 and newer.

Extends SingleChainMCMC.

References

[1](1, 2) 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.
[2](1, 2) Betancourt, M. (2018). A Conceptual Introduction to Hamiltonian Monte Carlo, https://arxiv.org/abs/1701.02434.
ask()[source]

See SingleChainMCMC.ask().

delta()[source]

Returns delta used in leapfrog algorithm.

divergent_iterations()[source]

Returns the iteration number of any divergent iterations.

hamiltonian_threshold()[source]

Returns threshold difference in Hamiltonian value from one iteration to next which determines whether an iteration is divergent.

in_initial_phase()

For methods that need an initial phase (see needs_initial_phase()), this method returns True if the method is currently configured to be in its initial phase. For other methods a NotImplementedError is returned.

max_tree_depth()[source]

Returns the maximum tree depth D for the algorithm. For each iteration, the number of leapfrog steps will not be greater than 2^D.

n_hyper_parameters()[source]

See TunableMethod.n_hyper_parameters().

name()[source]

See pints.MCMCSampler.name().

needs_initial_phase()

Returns True if this method needs an initial phase, for example an adaptation-free period for adaptive covariance methods, or a warm-up phase for DREAM.

needs_sensitivities()[source]

See pints.MCMCSampler.needs_sensitivities().

number_adaption_steps()[source]

Returns number of adaption steps used in the NUTS algorithm.

replace(current, current_log_pdf, proposed=None)

Replaces the internal current position, current LogPDF, and proposed point (if any) by the user-specified values.

This method can only be used once the initial position and LogPDF have been set (so after at least 1 round of ask-and-tell).

This is an optional method, and some samplers may not support it.

set_delta(delta)[source]

Sets delta for the nuts algorithm. This is the goal acceptance probability for the algorithm. Used to set the scalar magnitude of the leapfrog step size.

set_hamiltonian_threshold(hamiltonian_threshold)[source]

Sets threshold difference in Hamiltonian value from one iteration to next which determines whether an iteration is divergent.

set_hyper_parameters(x)[source]

The hyper-parameter vector is [number_adaption_steps].

See TunableMethod.set_hyper_parameters().

set_initial_phase(in_initial_phase)

For methods that need an initial phase (see needs_initial_phase()), this method toggles the initial phase algorithm. For other methods a NotImplementedError is returned.

set_max_tree_depth(max_tree_depth)[source]

Sets the maximum tree depth D for the algorithm. For each iteration, the number of leapfrog steps will not be greater than 2^D

set_number_adaption_steps(n)[source]

Sets number of adaptions steps in the nuts algorithm. This is the number of mcmc steps that are used to determin the best value for epsilon, the scalar magnitude of the leafrog step size.

set_use_dense_mass_matrix(use_dense_mass_matrix)[source]

If use_dense_mass_matrix is False then algorithm uses a diagonal matrix for the mass matrix. If True then a fully dense mass matrix is used.

tell(reply)[source]

See pints.SingleChainMCMC.tell().

use_dense_mass_matrix()[source]

Returns if the algorithm uses a dense (True) or diagonal (False) mass matrix.