MultilevelChainSamplers.jl
Table of contents
Table of contents
MCMC Sampler for multilevel delayed acceptance.
Usage
Proposal generators
List of built-in proposals
MultilevelChainSampler.StaticProposal
— TypeStaticProposal(d::Distribution)
Indepent proposal from a distribution
MultilevelChainSampler.RandomWalk
— TypeRandomWalk(init, step)
Sample from a random walk. The proposal is symmetric if the mean of the step distribution is zero.
MultilevelChainSampler.TransformedProposal
— TypeTransformedProposal(t, p)
Modify proposal p
with transformation t
. The transformation t
must implement a method for the type of p
.
MultilevelChainSampler.StackedProposal
— TypeStackedProposal(p...)
Stacked proposal that samples each component independently. The proposal is symmetric if all components are symmetric.
MultilevelChainSampler.ComponentwiseProposal
— TypeComponentwiseProposal(p...)
Component-wise proposal that samples each component independently. The proposal is symmetric if all components are symmetric. Like StackedProposal
` but with different change sizes for each component.
Custom Proposal generator
To define a custom proposal inherit from the abstract type
struct MyProposal <: AbstractProposal{issymmetric::Bool}
# ...
end
MultilevelChainSampler.propose
— Functionpropose(p, [x])
Propose a new state from the proposal distribution p
. If x
is given, propose a new state from the proposal distribution p
conditioned on x
.
Implement the sampling methods
- initialization x₀ ~ p₀(⋅) by
x₀ = propose(p)
- and transition y ~ q(⋅|x) by
y = propose(p, x)
propose(rng::AbstractRNG, p::MyProposal) = ...
propose(rng::AbstractRNG, p::MyProposal, x) = ...
For symmetric proposals q(x|y) = q(y|x)
and the likelihood ratio can be neglected. For asymmetric proposals also implement method for calculating q(y|x)
logpdf(p::AbstractProposal{false},x,y) = ...
Sampling
Implements the AbstractMCMC
sampling interface.
In a nutshell the sampling function takes the form
sample(t::LogDensity, mh::Sampler, N_or_isdone, options...)
The target t
is a logarithmic unnormalized probability density
MultilevelChainSampler.LogDensity
— TypeLogDensity(d::Distribution)
Wrap a distribution as a log density model using the logpdf
function.
LogDensity(f::Function)
Wrap a function as a unnormalized log density model.
In particular the options includes thread and process parallel sampling.
Metropolis Hastings (MH)
MultilevelChainSampler.MH
— TypeMH(p::AbstractProposal; save_logprob=false, save_reject=false)
Metropolis Hastings sampler with proposal p
.
save_logprob
: saves target evaluationssave_reject
: saves rejection status
Published in [1].
Multilevel Delayed Acceptance (MLDA)
Construct a multilevel proposal as vector of simple proposals.
MultilevelChainSampler.MLDA
— TypeMLDA(p::Vector{<:AbstractProposal}, n::Vector{<:Union{Integer,Distribution}};
save_logprob=false, save_reject=false, save_subchain=false)
Construct a multilevel delayed acceptance sampler from proposal vector p
and subchain length vector n
. They can either be fixed integers or distributions that are sampled at each iteration.
save_logprob
: saves target evaluationssave_reject
: saves rejection statussave_subchain
: saves subchain samples
Published in [1].
Reference
Index
MultilevelChainSampler.ComponentwiseProposal
MultilevelChainSampler.LogDensity
MultilevelChainSampler.MH
MultilevelChainSampler.MLDA
MultilevelChainSampler.RandomWalk
MultilevelChainSampler.StackedProposal
MultilevelChainSampler.StaticProposal
MultilevelChainSampler.TransformedProposal
MultilevelChainSampler.propose
Citations
[1] Hastings, W.K. (1970). "Monte Carlo Sampling Methods Using Markov Chains and Their Applications". Biometrika, Volume 57, Issue 1[2] Mikkel B. Lykkegaard, T. Dodwell, C. Fox, Grigorios Mingas, Robert Scheichl (2022). "Multilevel Delayed Acceptance MCMC" SIAM/ASA J. Uncertain. Quantification