anthofflab / RobustAdaptiveMetropolisSampler.jl

A Julia implementation of the RAM algorithm (Vihola, 2012)
MIT License
10 stars 2 forks source link
julia mcmc

RobustAdaptiveMetropolisSampler

Project Status: WIP – Initial development is in progress, but there has not yet been a stable, usable release suitable for the public. codecov

Overview

This package implements the robust adaptive metropolis (RAM) sampler described in Vihola (2012) for the Julia language.

Usage

The RAM_sample function runs a MCMC sampler on a given log target function. The arguments for the functions are as follows:

RAM_sample(logtarget, x0, M0, n; opt_α=0.234, γ=2/3, q=Normal(), show_progress=true)

The function returns a NamedTuple with three (or optionally four) elements:

A simple example of using the function is

using Distributions, RobustAdaptiveMetropolisSampler

chain, accrate, S = RAM_sample(
    p -> logpdf(Normal(3., 2), p[1]), # log target function
    [0.],                             # Initial value
    0.5,                              # Use an isotropic covariance matrix with diagonal elements abs2(0.5)
    100_000                           # Number of runs
)