Skip to content

Latest commit

 

History

History
54 lines (35 loc) · 1.85 KB

README.md

File metadata and controls

54 lines (35 loc) · 1.85 KB

Walker2014Sampling

Stable Dev Build Status codecov

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

Installation

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

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

or

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

Usage

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.

References

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#