gemlib.mcmc.transform_sampling_algorithm#
- gemlib.mcmc.transform_sampling_algorithm(bijectors, sampling_algorithm)#
Transform a sampling algorithm.
This wrapper transforms sampling_algorithm with respect to the probability measure on which it acts. transform_sampling_algorithm is particularly useful for unbounding parameter spaces in order to use algorithms such as Hamiltonian Monte Carlo or the No-U-Turn-Samplers (NUTS).
It does this by applying the change-of-variables formula, such that for \(Y = g(X)\),
\[f_Y(y)=f_X(g^{-1}(y))\left|\frac{\mathrm{d}g^{-1}(y)}{\mathrm{d}y}\right|\]- Parameters:
bijectors (Iterable) – a structure of TensorFlow Probability bijectors compatible with position
sampling_algorithm (SamplingAlgorithm) – a sampling algorithm
- Returns:
A new
SamplingAlgorithmrepresenting a kernel working on the transformed space.
Examples
Instantiate a transformed hmc kernel:
import tensorflow_probability as tfp from gemlib.mcmc import transform_sampling_algorithm from gemlib.mcmc import hmc kernel = transform_sampling_algorithm( bijectors=[tfp.bijectors.Exp(), tfp.bijectors.Exp()], sampling_algorithm=hmc(step_size=0.1, num_leapfrog_steps=16), )