Liking cljdoc? Tell your friends :D

org.replikativ.foerster.moves.block-mh

Random-walk Metropolis on block sites (foerster.block), run on the block's θ vector: a move takes several Gaussian steps against the block's own density and writes the result back to the trace once, as NUTS does (foerster.moves.nuts), so the trace replay is paid per move rather than per density evaluation.

The density is the block's target, or at temperature β the geometric path q^(1-β)·t^β from its draw density q to its target t (tempered SMC, foerster.inference.tempering). The block's target must be the complete conditional of its latents: a write-back that changes the log probability of anything outside the block is refused (::incomplete-target).

within-gibbs is the step of the random-walk MH kernel: block sites move this way, with per-coordinate scales adapted during the chain's :burn iterations (a diagonal adaptive Metropolis whose overall scale steers the acceptance rate toward 0.234), then one single-site random-walk move of a latent that is not a block site, if there is one. A trace without block sites makes the same moves as before.

Random-walk Metropolis on block sites (`foerster.block`), run on the
block's θ vector: a move takes several Gaussian steps against the block's
own density and writes the result back to the trace once, as NUTS does
(`foerster.moves.nuts`), so the trace replay is paid per move rather than per
density evaluation.

The density is the block's target, or at temperature β the geometric path
q^(1-β)·t^β from its draw density q to its target t (tempered SMC,
`foerster.inference.tempering`). The block's target must be the complete conditional
of its latents: a write-back that changes the log probability of anything
outside the block is refused (`::incomplete-target`).

`within-gibbs` is the step of the random-walk MH kernel: block sites move
this way, with per-coordinate scales adapted during the chain's `:burn`
iterations (a diagonal adaptive Metropolis whose overall scale steers the
acceptance rate toward 0.234), then one single-site random-walk move of a
latent that is not a block site, if there is one. A trace without block
sites makes the same moves as before.
raw docstring

org.replikativ.foerster.moves.hmc

Hamiltonian Monte Carlo on block sites (foerster.block), within Gibbs.

A block supplies the gradient of its log target; the move is spindel's. The momentum is drawn from the site's stream, leapfrog integrates with the block's :value+grad, and the endpoint is proposed by replaying the computation from the block site. It is accepted on the change of the FULL trace log joint plus the kinetic energy, not on the block's own value:

log α = [log p(trace') − K(p')] − [log p(trace) − K(p)] + log q(rev)/q(fwd)

where the last term, as in single-site MH (trace/mh-log-ratio), covers the sites the replay drew afresh or no longer reaches.

Leapfrog is volume preserving and reversible for any position-dependent force, so the move is exact whatever the block's target covers. A block whose target misses factors its latents affect (a downstream observe, a dependent site) mixes worse, and the step says so: :incomplete-target? is true when the replay changed the log probability of anything outside the block.

Hamiltonian Monte Carlo on block sites (`foerster.block`), within Gibbs.

A block supplies the gradient of its log target; the move is spindel's. The
momentum is drawn from the site's stream, leapfrog integrates with the
block's `:value+grad`, and the endpoint is proposed by replaying the
computation from the block site. It is accepted on the change of the FULL
trace log joint plus the kinetic energy, not on the block's own value:

  log α = [log p(trace') − K(p')] − [log p(trace) − K(p)] + log q(rev)/q(fwd)

where the last term, as in single-site MH (`trace/mh-log-ratio`), covers
the sites the replay drew afresh or no longer reaches.

Leapfrog is volume preserving and reversible for any position-dependent
force, so the move is exact whatever the block's target covers. A block
whose target misses factors its latents affect (a downstream observe, a
dependent site) mixes worse, and the step says so: `:incomplete-target?`
is true when the replay changed the log probability of anything outside the
block.
raw docstring

org.replikativ.foerster.moves.involutive

Involutive MCMC over savepoint traces (Neklyudov et al. 2020; Gen's involutive_mh).

A move draws auxiliary variables u ~ q(· ; x) from the current choices x, maps (x, u) through an involution h to (x', u'), replays the program with x', and accepts with

log α = log p(x') − log p(x) + log q(u' ; x') − log q(u ; x) + log |det ∂h/∂(x,u)|

Random-walk, scale, swap and data-driven moves are all such pairs (q, h). The Jacobian term is the caller's (:log-jacobian from the involution, required; 0.0 for a discrete or volume-preserving map); fd-log-jacobian computes it numerically for real-valued maps — raster's AD is the intended replacement.

Moves may change the set of sites (reversible jump; Green 1995): the involution sets the sites of the new dimension through :choices (new addresses included) and names under :removed the sites whose values it moved into the auxiliary variables — those are part of the state, not dropped. A site the replay reaches afresh without the involution setting it is drawn from its prior, and one it no longer reaches and that is not :removed is dropped, both scored as in single-site MH.

Involutive MCMC over savepoint traces (Neklyudov et al. 2020; Gen's
`involutive_mh`).

A move draws auxiliary variables u ~ q(· ; x) from the current choices x,
maps (x, u) through an involution h to (x', u'), replays the program with
x', and accepts with

  log α = log p(x') − log p(x) + log q(u' ; x') − log q(u ; x) + log |det ∂h/∂(x,u)|

Random-walk, scale, swap and data-driven moves are all such pairs (q, h).
The Jacobian term is the caller's (`:log-jacobian` from the involution,
required; 0.0 for a discrete or volume-preserving map);
`fd-log-jacobian` computes it numerically for real-valued maps — raster's AD
is the intended replacement.

Moves may change the set of sites (reversible jump; Green 1995): the
involution sets the sites of the new dimension through `:choices` (new
addresses included) and names under `:removed` the sites whose values it
moved into the auxiliary variables — those are part of the state, not
dropped. A site the replay reaches afresh without the involution setting
it is drawn from its prior, and one it no longer reaches and that is not
`:removed` is dropped, both scored as in single-site MH.
raw docstring

org.replikativ.foerster.moves.kernel

Inference kernels: what decides a particle's latent sites.

A PInferenceKernel decides a particle's latent sites during execution: inference/kernel-infer runs savepoint SMC whose sample sites take the value the kernel's step gives, which makes importance sampling vs SMC a choice of proposal policy, not of engine. PMarkovKernel describes transitions that foerster.moves.transition compiles and runs over traces.

Inference kernels: what decides a particle's latent sites.

A `PInferenceKernel` decides a particle's latent sites during execution:
`inference/kernel-infer` runs savepoint SMC whose sample sites take the
value the kernel's `step` gives, which makes importance sampling vs SMC a
choice of proposal policy, not of engine. `PMarkovKernel` describes
transitions that `foerster.moves.transition` compiles and runs over traces.
raw docstring

org.replikativ.foerster.moves.nuts

The No-U-Turn sampler on block sites (foerster.block), within Gibbs, as Stan implements it: multinomial sampling over the trajectory, the generalized no-U-turn criterion with the checks across merged subtrees (Hoffman & Gelman 2014; Betancourt 2017), divergences when the energy error exceeds 1000, a diagonal metric, and during warm-up dual-averaging step size adaptation and windowed variance estimation of the metric (Stan's 75/25/50 windows, scaled to short warm-ups). Stan's step size heuristic (init_stepsize: double or halve until one leapfrog step's acceptance crosses 0.8) runs as warm-up begins and after every metric window, and dual averaging restarts from it, at μ = log 10ε. As warm-up begins this deliberately deviates from Stan, whose first μ is log 10ε of its configured step size (default 1): here it comes from the heuristic's ε, as at every later restart, so the first window does not start from a scale-blind guess.

NUTS samples the block's own density, so the block's target must be the complete conditional of its latents (:block/target :complete-conditional): every factor they touch inside the block, and no other site depending on them. A replay that changes the log probability of anything outside the block is refused (::incomplete-target, its :changed the sites whose score moved). Put a hierarchy into one block, or move such a block with HMC (foerster.moves.hmc) or delayed acceptance (foerster.moves.block-mh), which accept on the full trace (doc/algorithms.md, section NUTS within Gibbs needs complete conditionals).

Each chain starts at its block sites' :init plus U(−2, 2) per coordinate of θ (jitter), unless :jitter false — also with :burn 0, where every draw is kept: to resume a frozen chain from a posterior draw, pass that draw as :init with :jitter false. :step-size and :inverse-metric set where warm-up starts, or with :burn 0 the frozen values NUTS runs at; the sampler statistics report them.

The kernel is (k/nuts-kernel iterations {:burn … :target-accept 0.8 :max-depth 10}): the first :burn iterations adapt and are dropped.

The No-U-Turn sampler on block sites (`foerster.block`), within Gibbs, as
Stan implements it: multinomial sampling over the trajectory, the
generalized no-U-turn criterion with the checks across merged subtrees
(Hoffman & Gelman 2014; Betancourt 2017), divergences when the energy error
exceeds 1000, a diagonal metric, and during warm-up dual-averaging step
size adaptation and windowed variance estimation of the metric (Stan's
75/25/50 windows, scaled to short warm-ups). Stan's step size heuristic
(`init_stepsize`: double or halve until one leapfrog step's acceptance
crosses 0.8) runs as warm-up begins and after every metric window, and
dual averaging restarts from it, at μ = log 10ε. As warm-up begins this
deliberately deviates from Stan, whose first μ is log 10ε of its
configured step size (default 1): here it comes from the heuristic's ε,
as at every later restart, so the first window does not start from a
scale-blind guess.

NUTS samples the block's own density, so the block's target must be the
complete conditional of its latents (`:block/target
:complete-conditional`): every factor they touch inside the block, and no
other site depending on them. A replay that changes the log probability
of anything outside the block is refused (`::incomplete-target`, its
`:changed` the sites whose score moved). Put a hierarchy into one block,
or move such a block with HMC (`foerster.moves.hmc`) or delayed acceptance
(`foerster.moves.block-mh`), which accept on the full trace (doc/algorithms.md,
section NUTS within Gibbs needs complete conditionals).

Each chain starts at its block sites' `:init` plus U(−2, 2) per
coordinate of θ (`jitter`), unless `:jitter false` — also with `:burn
0`, where every draw is kept: to resume a frozen chain from a posterior
draw, pass that draw as `:init` with `:jitter false`. `:step-size` and
`:inverse-metric` set where warm-up starts, or with `:burn 0` the frozen
values NUTS runs at; the sampler statistics report them.

The kernel is `(k/nuts-kernel iterations {:burn … :target-accept 0.8
:max-depth 10})`: the first `:burn` iterations adapt and are dropped.
raw docstring

org.replikativ.foerster.moves.transition

Compilation and execution of Markov kernels. Site proposal policies and weighted population operations do not pass through this interpreter.

Compilation and execution of Markov kernels. Site proposal policies and
weighted population operations do not pass through this interpreter.
raw docstring

org.replikativ.foerster.moves.transition-context

Target, replay and ownership context shared by numerical and trace moves.

Target, replay and ownership context shared by numerical and trace moves.
raw docstring

org.replikativ.foerster.moves.transport

Scored forward/backward transport. The caller supplies valid auxiliary proposal laws and the change-of-variables Jacobian; these are not inferred. The Jacobian must be stated (:log-jacobian, 0.0 for a discrete or volume-preserving map): a forgotten one would silently bias the weights.

Scored forward/backward transport. The caller supplies valid auxiliary
proposal laws and the change-of-variables Jacobian; these are not inferred.
The Jacobian must be stated (`:log-jacobian`, 0.0 for a discrete or
volume-preserving map): a forgotten one would silently bias the weights.
raw 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