blackjax.mcmc.dynamic_hmc#
Public API for the Dynamic HMC Kernel
Classes#
State of the dynamic HMC algorithm. |
Functions#
|
|
|
Build a Dynamic HMC kernel where the number of integration steps is chosen randomly. |
|
Implements the (basic) user interface for the dynamic HMC kernel. |
|
Generate the (i+1)-th element of the Halton sequence. |
Module Contents#
- class DynamicHMCState[source]#
State of the dynamic HMC algorithm.
Adds a utility array for generating a pseudo or quasi-random sequence of number of integration steps.
- init(position: blackjax.types.ArrayLikeTree, logdensity_fn: Callable, random_generator_arg: blackjax.types.Array)[source]#
- build_kernel(integrator: Callable = integrators.velocity_verlet, divergence_threshold: float = 1000, next_random_arg_fn: Callable = lambda key: ..., integration_steps_fn: Callable = lambda key: ..., build_proposal: Callable = hmc_proposal)[source]#
Build a Dynamic HMC kernel where the number of integration steps is chosen randomly.
- Parameters:
integrator – The symplectic 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 – Callable with signature
(random_generator_arg, *integration_steps_params) -> intthat draws the number of integration steps for a single transition. Extra positional arguments beyondrandom_generator_argare supplied at call time viaintegration_steps_paramson the inner kernel, so tunable parameters (e.g. average number of steps, distribution bounds) can be adapted without rebuilding the kernel.build_proposal – A callable with signature
(integrator, kinetic_energy, step_size, num_integration_steps, divergence_threshold) -> generatethat builds the proposal function. Defaults tohmc_proposal()(standard endpoint HMC).
- 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, inverse_mass_matrix: blackjax.types.Array, *, divergence_threshold: int = 1000, integrator: Callable = integrators.velocity_verlet, next_random_arg_fn: Callable = lambda key: ..., integration_steps_fn: Callable = lambda key: ..., integration_steps_params: tuple = (), build_proposal: Callable = hmc_proposal) blackjax.base.SamplingAlgorithm[source]#
Implements the (basic) user interface for the dynamic HMC 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.
inverse_mass_matrix – The value to use for the inverse mass matrix when drawing a value for the momentum and computing the kinetic energy.
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 – Callable with signature
(random_generator_arg, *integration_steps_params) -> intthat draws the number of integration steps for a single transition.integration_steps_params – Extra positional arguments unpacked into
integration_steps_fnafterrandom_generator_argon every step. Use this to pass tunable parameters (e.g.(avg_num_integration_steps,)or(lower_bound, upper_bound)) without rebuilding the kernel. Defaults to()so that a plain 1-argintegration_steps_fnworks unchanged.build_proposal – A callable with signature
(integrator, kinetic_energy, step_size, num_integration_steps, divergence_threshold) -> generatethat builds the proposal function. Defaults tohmc_proposal()(standard endpoint HMC). Passmultinomial_hmc_proposal()for multinomial trajectory sampling.
- Return type:
A
SamplingAlgorithm.