blackjax.mcmc.adjusted_mclmc_dynamic

blackjax.mcmc.adjusted_mclmc_dynamic#

Public API for the Metropolis Hastings Microcanonical Hamiltonian Monte Carlo (MHMCHMC) Kernel. This is closely related to the Microcanonical Langevin Monte Carlo (MCLMC) Kernel, which is an unadjusted method. This kernel adds a Metropolis-Hastings correction to the MCLMC kernel. It also only refreshes the momentum variable after each MH step, rather than during the integration of the trajectory. Hence “Hamiltonian” and not “Langevin”.

Functions#

init(position, logdensity_fn, random_generator_arg)

build_kernel(integration_steps_fn[, integrator, ...])

Build a Dynamic MHMCHMC kernel where the number of integration steps is chosen randomly.

as_top_level_api([1], integration_steps_fn, 1, ...)

Implements the (basic) user interface for the dynamic MHMCHMC kernel.

Module Contents#

init(position: blackjax.types.ArrayLikeTree, logdensity_fn: Callable, random_generator_arg: blackjax.types.Array)[source]#
build_kernel(integration_steps_fn, integrator: Callable = integrators.isokinetic_mclachlan, divergence_threshold: float = 1000, next_random_arg_fn: Callable = lambda key: ..., inverse_mass_matrix=1.0)[source]#

Build a Dynamic MHMCHMC kernel where the number of integration steps is chosen randomly.

Parameters:
  • integrator – The integrator to use to integrate the Hamiltonian dynamics.

  • divergence_threshold – Value of the difference in energy above which we consider that the transition is divergent.

  • next_random_arg_fn – Function that generates the next random_generator_arg from its previous value.

  • integration_steps_fn – Function that generates the next pseudo or quasi-random number of integration steps in the sequence, given the current random_generator_arg. Needs to return an int.

Returns:

  • A kernel that takes a rng_key and a Pytree that contains the current state

  • of the chain and that returns a new state of the chain along with

  • information about the transition.

as_top_level_api(logdensity_fn: Callable, step_size: float, L_proposal_factor: float = jnp.inf, inverse_mass_matrix=1.0, *, divergence_threshold: int = 1000, integrator: Callable = integrators.isokinetic_mclachlan, next_random_arg_fn: Callable = lambda key: ..., integration_steps_fn: Callable = lambda key: ...) blackjax.base.SamplingAlgorithm[source]#

Implements the (basic) user interface for the dynamic MHMCHMC kernel.

Parameters:
  • logdensity_fn – The log-density function we wish to draw samples from.

  • step_size – The value to use for the step size in the symplectic integrator.

  • divergence_threshold – The absolute value of the difference in energy between two states above which we say that the transition is divergent. The default value is commonly found in other libraries, and yet is arbitrary.

  • integrator – (algorithm parameter) The symplectic integrator to use to integrate the trajectory.

  • next_random_arg_fn – Function that generates the next random_generator_arg from its previous value.

  • integration_steps_fn – Function that generates the next pseudo or quasi-random number of integration steps in the sequence, given the current random_generator_arg.

Return type:

A SamplingAlgorithm.