This is a simple implementation of "AutoMALA: Locally Adaptive Metropolis-Adjusted Langevin Algorithm" by Biron-Lattes, Surjanovic & Syed et al. (2023)
, i.e. MALA but with a step size that is allowed to change in a reversible manner.
Note that this is mainly meant as a demonstration of how to implement samplers in AbstractMCMC.jl and rather than a production ready sampler implementation.
It is easy to use AutoMALA
with Turing.jl through the Turing.externalsampler
interface:
using AutomaticMALA, Turing
# Define the model using Turing.jl.
@model function demo()
s ~ InverseGamma(2, 3)
m ~ Normal(0, sqrt(s))
1.5 ~ Normal(m, sqrt(s))
2.0 ~ Normal(m, sqrt(s))
end
model = demo()
# Set up the sampler.
num_adapts = 1000
sampler = AutoMALA(ϵ_init=1.0, num_unadjusted=num_adapts)
# Perform inference.
chain = sample(model, externalsampler(sampler), 1000; discard_initial=num_adapts)