Liking cljdoc? Tell your friends :D

org.replikativ.foerster.parallel-tempering

Non-reversible parallel tempering (Syed, Bouchard-Côté, Deligiannidis & Doucet 2022) on a model that is one block (foerster.population).

N + 1 chains sit on the path π_β ∝ q^(1−β)·t^β from the block's draw density q (the reference) to its target t, at 0 = β_0 < … < β_N = 1. A scan explores every chain at its own β (the reference chain by an exact draw, the others by random-walk Metropolis), then offers swaps to neighbours: even pairs on even scans, odd pairs on odd scans. A swap of chains i and i+1 is accepted with min(1, exp((β_{i+1} − β_i)·(V(x_i) − V(x_{i+1})))), V = log t − log q.

The schedule is tuned in rounds of doubling length: the swap rejection rates r_i give the cumulative barrier Λ(β_i) = Σ_{j<i} r_j, and the next round spaces its β evenly in Λ. Λ(1) is the global communication barrier.

The last round's states of the target chain are the posterior sample; the log evidence (q normalized) is the stepping-stone estimate Σ_i log mean exp((β_{i+1} − β_i)·V) over chain i's states.

Non-reversible parallel tempering (Syed, Bouchard-Côté, Deligiannidis &
Doucet 2022) on a model that is one block (`foerster.population`).

N + 1 chains sit on the path π_β ∝ q^(1−β)·t^β from the block's draw
density q (the reference) to its target t, at 0 = β_0 < … < β_N = 1. A
scan explores every chain at its own β (the reference chain by an exact
draw, the others by random-walk Metropolis), then offers swaps to
neighbours: even pairs on even scans, odd pairs on odd scans. A swap of
chains i and i+1 is accepted with min(1, exp((β_{i+1} − β_i)·(V(x_i) −
V(x_{i+1})))), V = log t − log q.

The schedule is tuned in rounds of doubling length: the swap rejection
rates r_i give the cumulative barrier Λ(β_i) = Σ_{j<i} r_j, and the next
round spaces its β evenly in Λ. Λ(1) is the global communication barrier.

The last round's states of the target chain are the posterior sample; the
log evidence (q normalized) is the stepping-stone estimate
Σ_i log mean exp((β_{i+1} − β_i)·V) over chain i's states.
raw docstring

evenly-in-barrierclj/s

(evenly-in-barrier betas lambdas n)

n + 1 temperatures spaced evenly in the cumulative barrier through the points (β_i, Λ_i), by inverting its piecewise-linear interpolation.

`n` + 1 temperatures spaced evenly in the cumulative barrier through the
points (β_i, Λ_i), by inverting its piecewise-linear interpolation.
sourceraw docstring

parallel-temperingclj/s

(parallel-tempering model
                    &
                    [{:keys [chains steps executor]
                      n-rounds :rounds
                      :or {chains 10 n-rounds 10}}])

Non-reversible parallel tempering of model (a spin) that is one block with a :sample and :sample-log-density (the reference). Options:

:chains N + 1, the number of temperatures (default 10; about twice the barrier Λ the result reports is enough) :rounds tuning rounds of 1, 2, 4, … scans (default 10); the last round's 2^(rounds−1) target-chain states are the sample :steps random-walk steps per chain per scan (default the dimension) :executor the worlds' executor

Returns a CPS operation resolving an EmpiricalMeasure of Samples, each written back to a trace once per distinct θ, whose m/log-marginal is the stepping-stone evidence; :temperatures, :barrier Λ, :local-barrier [[β r] …], :round-trips and :swap-acceptance diagnose the run.

Non-reversible parallel tempering of `model` (a spin) that is one block
with a `:sample` and `:sample-log-density` (the reference). Options:

  :chains   N + 1, the number of temperatures (default 10; about twice the
            barrier Λ the result reports is enough)
  :rounds   tuning rounds of 1, 2, 4, … scans (default 10); the last
            round's 2^(rounds−1) target-chain states are the sample
  :steps    random-walk steps per chain per scan (default the dimension)
  :executor the worlds' executor

Returns a CPS operation resolving an EmpiricalMeasure of `Sample`s, each
written back to a trace once per distinct θ, whose `m/log-marginal` is the
stepping-stone evidence; `:temperatures`, `:barrier` Λ, `:local-barrier`
[[β r] …], `:round-trips` and `:swap-acceptance` diagnose the run.
sourceraw docstring

rest-ofclj/s

(rest-of logpdf draw-logpdf)

V(θ) = log t(θ) − log q(θ) of a block law.

V(θ) = log t(θ) − log q(θ) of a block law.
sourceraw docstring

roundsclj/s

(rounds xs v explore-at {:keys [n-rounds seed dim steps]})

Run n-rounds rounds of 1, 2, 4, … scans from the chains' states xs, retuning the schedule after each. explore-at (fn [scales] (fn [i beta x] …)) builds a round's explorer from per-chain step scales, which adapt toward 0.234 acceptance from round to round. Returns the last round's {:samples :log-z :betas :barrier :local-barrier :round-trips :swap-acceptance :scans}.

Run `n-rounds` rounds of 1, 2, 4, … scans from the chains' states `xs`,
retuning the schedule after each. `explore-at` (fn [scales] (fn [i beta x]
…)) builds a round's explorer from per-chain step scales, which adapt
toward 0.234 acceptance from round to round. Returns the last round's
{:samples :log-z :betas :barrier :local-barrier :round-trips
:swap-acceptance :scans}.
sourceraw docstring

scanclj/s

(scan {:keys [betas] :as st} r s v explore seed)

One scan of round r, number s: every chain explored by (explore i beta x) -> {:x :accepted} under its stream, then the swaps of parity s. st holds :xs :betas :labels :replicas and the round's tallies :rej :acc :swaps :swapped :vs :samples.

One scan of round `r`, number `s`: every chain explored by
`(explore i beta x)` -> {:x :accepted} under its stream, then the swaps
of parity s. `st` holds :xs :betas :labels :replicas and the round's
tallies :rej :acc :swaps :swapped :vs :samples.
sourceraw docstring

stepping-stoneclj/s

(stepping-stone betas vs)

log Z of the target relative to the reference: Σ_i log mean exp((β_{i+1} − β_i)·V) over chain i's V values vs.

log Z of the target relative to the reference: Σ_i log mean
exp((β_{i+1} − β_i)·V) over chain i's V values `vs`.
sourceraw docstring

swap-log-ratioclj/s

(swap-log-ratio b0 b1 v0 v1)

log acceptance of swapping the states of chains at b0 < b1 holding states with V values v0 and v1.

log acceptance of swapping the states of chains at `b0` < `b1` holding
states with V values `v0` and `v1`.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close