Sampling from an unnormalized pmf in Julia using Walker's MCMC algorithm.
Author igutierrezm
0 Stars
Updated Last
1 Year Ago
Started In
April 2021


Stable Dev Build Status codecov

Sampling from an unnormalized pmf in Julia using Walker's MCMC algorithm, see Walker (2014) for details.


Install with the Julia package manager Pkg, just like any other registered Julia package:

# Press ']' to enter the Pkg REPL mode.
pkg> add Walker2014Sampling


julia> using Pkg; 
julia> Pkg.add("Walker2014Sampling")


Suppose we want to draw the next state in a MCMC with target (unnormalized) pmf p() using Walker's algorithm with parameter k. Suppose further that the support of p() is ℕ and the current state is x0.

The first step is to set up the environment:

using Random, Walker2014Sampling
rng = MersenneTwister(1)

Then, we create a sampler s using Walker2014Sampler():

s = Walker2014Sampler(k);

Finally, we draw the next state using rand():

x1 = rand(rng, p, s, x0);

Be aware that both rng and s are modified in the process.


Walker, S. G. (2014). Sampling unnormalized probabilities: An alternative to the Metropolis--Hastings algorithm. SIAM Journal on Scientific Computing, 36(2), A482–A494. https://doi.org/10.1137/130922549#