From d410a729cc1f7a33adc2caa7d12306b651ac09fa Mon Sep 17 00:00:00 2001 From: waldie11 <86674066+waldie11@users.noreply.github.com> Date: Mon, 5 Sep 2022 10:55:59 +0200 Subject: [PATCH] feature sequential application of RAM_sample --- README.md | 1 + src/RobustAdaptiveMetropolisSampler.jl | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a0db79f..dc2578e 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ RAM_sample(logtarget, x0, M0, n; opt_α=0.234, γ=2/3, q=Normal(), show_progress * `γ`: a parameter for the computation of the step size sequence. * `q`: the proposal distribution. * `show_progress`: a flag that controls whether a progress bar is shown. +* `nsampled`: in sequential application of `RAM_sample`, provide the number of global steps so far to yield consistent updates on the covariance matrix. * `output_log_probability_x`: a flag that controls whether to include output for the log-posterior scores from each Markov chain iteration. The function returns a `NamedTuple` with three (or optionally four) elements: diff --git a/src/RobustAdaptiveMetropolisSampler.jl b/src/RobustAdaptiveMetropolisSampler.jl index 19fb749..3afd3b6 100644 --- a/src/RobustAdaptiveMetropolisSampler.jl +++ b/src/RobustAdaptiveMetropolisSampler.jl @@ -32,6 +32,7 @@ function RAM_sample( γ=2 / 3, q=Normal(), show_progress::Bool=true, + nsampled::Int=0, output_log_probability_x::Bool=false ) @@ -85,7 +86,9 @@ function RAM_sample( # Step R3 # This is taken from the second paragraph of section 5 - η = min(1, d * i^-γ) + # A sequential application of RAM_Sample requires knowledge on the number of already + # processed steps. + η = min(1, d * (nsampled + i)^-γ) # Compute the new covariance matrix M = s.L * (I + η * (α - opt_α) * (u * u') / norm(u)^2 ) * s.L'