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 kernel, not of engine. The Markov-chain kernels (single-site and
random-walk MH, block Gibbs, HMC) are descriptions that kernel-infer runs
as replay plus accept 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 kernel, not of engine. The Markov-chain kernels (single-site and random-walk MH, block Gibbs, HMC) are descriptions that `kernel-infer` runs as replay plus accept over traces.
(block-gibbs-kernel num-iterations
block-selector
block-kernels
address-classifier
&
[opts])Create a BlockGibbsKernel for block Gibbs sampling.
Output options (all Markov-chain kernels): :samples :final (default)
emits each chain's last state; :samples :all emits every state after
the first :burn moves, equally weighted — an MCMC estimate from few
chains instead of one draw per chain.
Create a BlockGibbsKernel for block Gibbs sampling. Output options (all Markov-chain kernels): `:samples :final` (default) emits each chain's last state; `:samples :all` emits every state after the first `:burn` moves, equally weighted — an MCMC estimate from few chains instead of one draw per chain.
(cycle num-iterations kernels & [opts])A Markov-chain kernel that, num-iterations times, runs each of kernels
in turn — each for its own iterations: (cycle 100 [(hmc-kernel 1 …)
(single-site-mh-kernel 5)]) is a hundred rounds of one HMC move and five
single-site moves. A composition of kernels that leave the posterior
invariant leaves it invariant. Output options as for every chain kernel.
A Markov-chain kernel that, `num-iterations` times, runs each of `kernels` in turn — each for its own iterations: (cycle 100 [(hmc-kernel 1 …) (single-site-mh-kernel 5)]) is a hundred rounds of one HMC move and five single-site moves. A composition of kernels that leave the posterior invariant leaves it invariant. Output options as for every chain kernel.
(hmc-kernel num-iterations
&
[{:keys [step-size steps] :or {step-size 0.1 steps 10} :as opts}])Hamiltonian Monte Carlo on the block sites of a program
(foerster.block), within Gibbs: every iteration moves each block site by
HMC (:step-size, :steps leapfrog steps) and one other latent site by
single-site MH (foerster.hmc/within-gibbs). Output options as for every
Markov-chain kernel.
Hamiltonian Monte Carlo on the block sites of a program (`foerster.block`), within Gibbs: every iteration moves each block site by HMC (`:step-size`, `:steps` leapfrog steps) and one other latent site by single-site MH (`foerster.hmc/within-gibbs`). Output options as for every Markov-chain kernel.
(mixture num-iterations weighted & [opts])A Markov-chain kernel that, num-iterations times, picks one of the
kernels in weighted ([[w kernel] …]) with probability ∝ w and runs it
for its own iterations. A mixture of kernels that leave the posterior
invariant leaves it invariant (with weights that do not depend on the
state). Output options as for every chain kernel.
A Markov-chain kernel that, `num-iterations` times, picks one of the kernels in `weighted` ([[w kernel] …]) with probability ∝ w and runs it for its own iterations. A mixture of kernels that leave the posterior invariant leaves it invariant (with weights that do not depend on the state). Output options as for every chain kernel.
Protocol for block-level proposal kernels.
Protocol for block-level proposal kernels.
(propose-block this trace block-addresses)Returns {addr -> proposed-value} for addresses in this block.
Returns {addr -> proposed-value} for addresses in this block.
Protocol for selecting which block to update at each iteration.
Protocol for selecting which block to update at each iteration.
(select-block this trace iteration)Returns block-id (keyword) for which block to update this iteration.
Returns block-id (keyword) for which block to update this iteration.
Protocol for kernels that operate at the random choices of a particle.
It decides what value a latent site of a particle takes:
inference/kernel-infer asks its step at every sample site of savepoint
SMC.
Markov-chain kernels (single-site-mh-kernel, random-walk-mh-kernel,
block-gibbs-kernel, hmc-kernel) implement kernel-id only: they are
descriptions that inference/kernel-infer runs as replay plus accept over
traces (foerster.trace).
Protocol for kernels that operate at the random choices of a particle. It decides what value a latent site of a particle takes: `inference/kernel-infer` asks its `step` at every sample site of savepoint SMC. Markov-chain kernels (`single-site-mh-kernel`, `random-walk-mh-kernel`, `block-gibbs-kernel`, `hmc-kernel`) implement `kernel-id` only: they are descriptions that `inference/kernel-infer` runs as replay plus accept over traces (`foerster.trace`).
(kernel-id this)Unique identifier for this kernel type (e.g., :prior, :single-site-mh).
Unique identifier for this kernel type (e.g., :prior, :single-site-mh).
(step this ctx checkpoint trace)Decide a latent site of the particle whose world is ctx: checkpoint
is {:source distribution :options site-options :address address},
trace the particle's trace so far.
Returns {:value v} and optionally :log-weight-delta,
what the value adds to the particle's weight (default 0: a draw from the
site's distribution).
Decide a latent site of the particle whose world is `ctx`: `checkpoint`
is {:source distribution :options site-options :address address},
`trace` the particle's trace so far.
Returns {:value v} and optionally `:log-weight-delta`,
what the value adds to the particle's weight (default 0: a draw from the
site's distribution).(prior-kernel)Create a PriorKernel for simple importance sampling.
Create a PriorKernel for simple importance sampling.
(random-walk-block-kernel & [{:keys [step-size] :or {step-size 0.1}}])(random-walk-mh-kernel num-iterations
&
[{:keys [step-size] :or {step-size 0.1} :as opts}])Create RandomWalkMHKernel for continuous variables.
Metropolis-Hastings with a symmetric Gaussian proposal on one unobserved
site per iteration; the program is replayed from that site with every other
site held at its trace value and rescored, and the proposal is accepted on
the ratio of joint densities (see foerster.trace/mh-log-ratio). A
discrete site gets a prior proposal instead of a step.
Output options (all Markov-chain kernels): :samples :final (default)
emits each chain's last state; :samples :all emits every state after
the first :burn moves, equally weighted — an MCMC estimate from few
chains instead of one draw per chain.
Create RandomWalkMHKernel for continuous variables. Metropolis-Hastings with a symmetric Gaussian proposal on one unobserved site per iteration; the program is replayed from that site with every other site held at its trace value and rescored, and the proposal is accepted on the ratio of joint densities (see `foerster.trace/mh-log-ratio`). A discrete site gets a prior proposal instead of a step. Output options (all Markov-chain kernels): `:samples :final` (default) emits each chain's last state; `:samples :all` emits every state after the first `:burn` moves, equally weighted — an MCMC estimate from few chains instead of one draw per chain.
(single-site-mh-kernel num-iterations & [opts])Create SingleSiteMHKernel for lightweight Metropolis-Hastings.
Output options (all Markov-chain kernels): :samples :final (default)
emits each chain's last state; :samples :all emits every state after
the first :burn moves, equally weighted — an MCMC estimate from few
chains instead of one draw per chain.
Create SingleSiteMHKernel for lightweight Metropolis-Hastings. Output options (all Markov-chain kernels): `:samples :final` (default) emits each chain's last state; `:samples :all` emits every state after the first `:burn` moves, equally weighted — an MCMC estimate from few chains instead of one draw per chain.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |