Liking cljdoc? Tell your friends :D

org.replikativ.foerster.inference.compiled

A model whose structure is static given its data, compiled to plain functions of its latent values, and inference on them without worlds, savepoints or continuations.

compile-model reads the model's instance graph (analysis/instance): every site with a concrete address, a distribution written over constants and the latent sites before it, and no site whose existence depends on a value. It returns its latent addresses, a log density of a double array of their values (the sum of every site's log density, as a run of the model would score it) and a draw from the prior. rmh runs :rmh's moves (one latent drawn uniformly, a Gaussian step of :step-size) on that density: each move evaluates the density once, as Gen's dynamic MH re-runs its program once, but as compiled code.

A model that does not qualify is refused with the reasons, so a caller can fall back to the general path.

Scope: an opt-in (infer … {:method :rmh :compiled? true}), on the JVM only, for models whose latents are all continuous, and single-site random-walk MH only, with a fixed :step-size and the whole density evaluated per move (no incremental density). Positive and interval latents step in their own coordinates, a proposal outside the support being rejected, where the general path's block moves adapt scales in unconstrained coordinates. The chains are tasks of the run's executor.

A model whose structure is static given its data, compiled to plain
functions of its latent values, and inference on them without worlds,
savepoints or continuations.

`compile-model` reads the model's instance graph (`analysis/instance`):
every site with a concrete address, a distribution written over constants
and the latent sites before it, and no site whose existence depends on a
value. It returns its latent addresses, a log density of a double array
of their values (the sum of every site's log density, as a run of the
model would score it) and a draw from the prior. `rmh` runs `:rmh`'s
moves (one latent drawn uniformly, a Gaussian step of `:step-size`) on
that density: each move evaluates the density once, as Gen's dynamic MH
re-runs its program once, but as compiled code.

A model that does not qualify is refused with the reasons, so a caller
can fall back to the general path.

Scope: an opt-in (`infer … {:method :rmh :compiled? true}`), on the JVM
only, for models whose latents are all continuous, and single-site
random-walk MH only, with a fixed `:step-size` and the whole density
evaluated per move (no incremental density). Positive and interval
latents step in their own coordinates, a proposal outside the support
being rejected, where the general path's block moves adapt scales in
unconstrained coordinates. The chains are tasks of the run's executor.
raw docstring

compile-modelclj

(compile-model model & args)

The model applied to args compiled: {:addresses [a …] :log-density (fn [^doubles x]) :draw (fn [] ^doubles x)}, latent values in the order of :addresses. Throws ::not-static with the refusals when it cannot be.

The model applied to `args` compiled: {:addresses [a …] :log-density
(fn [^doubles x]) :draw (fn [] ^doubles x)}, latent values in the order of
:addresses. Throws ::not-static with the `refusals` when it cannot be.
sourceraw docstring

refusalsclj

(refusals {:keys [sites unknown result]})

Why the instance graph g cannot be compiled: a vector of reasons, empty when it can.

Why the instance graph `g` cannot be compiled: a vector of reasons, empty
when it can.
sourceraw docstring

rmhclj

(rmh {:keys [addresses log-density draw result]}
     {:keys [iterations burn step-size chains seed executor]
      :or {burn 0 chains 4 step-size 0.1}})

Random-walk MH on a compiled model (compile-model), as foerster.core's :rmh: :chains chains (default 4) of :iterations moves, each moving one latent drawn uniformly by a Gaussian step of :step-size (default 0.1); every state after the first :burn moves is kept. Each chain draws from a stream of its own, seeded from :seed (else from the process generator, in order), so its draws do not depend on where it runs. The chains are tasks of :executor (spread over its threads, as the other chain drivers'), or of a two-thread pool of the run's own. Resolves, as a CPS operation, an EmpiricalMeasure of the model's results with :chain-lengths; a sample's trace holds its latent values only.

Random-walk MH on a compiled model (`compile-model`), as `foerster.core`'s
`:rmh`: `:chains` chains (default 4) of `:iterations` moves, each moving
one latent drawn uniformly by a Gaussian step of `:step-size` (default
0.1); every state after the first `:burn` moves is kept. Each chain draws
from a stream of its own, seeded from `:seed` (else from the process
generator, in order), so its draws do not depend on where it runs. The
chains are tasks of `:executor` (spread over its threads, as the other
chain drivers'), or of a two-thread pool of the run's own. Resolves, as a
CPS operation, an EmpiricalMeasure of the model's results with
`:chain-lengths`; a sample's trace holds its latent values only.
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