Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/igutierrezm/walker2014sampling.jl
Sampling from an unnormalized pmf in Julia using Walker's MCMC algorithm.
https://github.com/igutierrezm/walker2014sampling.jl
julia mcmc walker-algorithm
Last synced: 25 days ago
JSON representation
Sampling from an unnormalized pmf in Julia using Walker's MCMC algorithm.
- Host: GitHub
- URL: https://github.com/igutierrezm/walker2014sampling.jl
- Owner: igutierrezm
- License: mit
- Created: 2021-04-11T23:42:17.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-05-17T19:56:53.000Z (over 3 years ago)
- Last Synced: 2024-11-07T01:29:04.632Z (2 months ago)
- Topics: julia, mcmc, walker-algorithm
- Language: Julia
- Homepage:
- Size: 142 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Walker2014Sampling
[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://igutierrezm.github.io/Walker2014Sampling.jl/stable)
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://igutierrezm.github.io/Walker2014Sampling.jl/dev)
[![Build Status](https://github.com/igutierrezm/Walker2014Sampling.jl/workflows/CI/badge.svg)](https://github.com/igutierrezm/Walker2014Sampling.jl/actions)
[![codecov](https://codecov.io/gh/igutierrezm/Walker2014Sampling.jl/branch/main/graph/badge.svg?token=o8DGQSTKft)](https://codecov.io/gh/igutierrezm/Walker2014Sampling.jl)Sampling from an unnormalized [pmf](https://en.wikipedia.org/wiki/Probability_mass_function) 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:
```julia
# Press ']' to enter the Pkg REPL mode.
pkg> add Walker2014Sampling
```or
```julia
julia> using Pkg;
julia> Pkg.add("Walker2014Sampling")
```## Usage
Suppose we want to draw the next state in a [MCMC](https://en.wikipedia.org/wiki/Markov_chain_Monte_Carlo) 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:
```julia
using Random, Walker2014Sampling
rng = MersenneTwister(1)
```Then, we create a sampler `s` using `Walker2014Sampler()`:
```julia
s = Walker2014Sampler(k);
```Finally, we draw the next state using `rand()`:
```julia
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#