Liking cljdoc? Tell your friends :D

org.replikativ.foerster.population

Particle populations on θ vectors: the shared engine of the samplers that move a model that is one block (foerster.block) without worlds.

A model that is one latent block site and nothing else is, for inference, its θ: its density is the block's, and the program around it only computes the result from θ. Such a model runs here on plain vectors, and a world is made only at the end, by one replay per distinct final θ (write-back-all), so every result is still computed by the program itself.

theta-smc is an SMC sampler over a sequence of targets on θ, given by a path: tempering from the block's draw density to its target is one path (foerster.tempering); data arriving in batches or a hierarchy of model levels are others. A path decides the next position from the population, gives each particle's incremental log weight to it, and the log density the moves at that position leave invariant. Resampling, the moves and the evidence are the engine's.

Randomness is keyed by what is drawn (foerster.random): the resampling at step k and the moves of chain i at step k read their own streams, under keys the caller names, so a sampler moved onto this engine keeps its draws.

Particle populations on θ vectors: the shared engine of the samplers that
move a model that is one block (`foerster.block`) without worlds.

A model that is one latent block site and nothing else is, for inference,
its θ: its density is the block's, and the program around it only computes
the result from θ. Such a model runs here on plain vectors, and a world is
made only at the end, by one replay per distinct final θ (`write-back-all`),
so every result is still computed by the program itself.

`theta-smc` is an SMC sampler over a sequence of targets on θ, given by a
path: tempering from the block's draw density to its target is one path
(`foerster.tempering`); data arriving in batches or a hierarchy of model
levels are others. A path decides the next position from the population,
gives each particle's incremental log weight to it, and the log density the
moves at that position leave invariant. Resampling, the moves and the
evidence are the engine's.

Randomness is keyed by what is drawn (`foerster.random`): the resampling
at step k and the moves of chain i at step k read their own streams, under
keys the caller names, so a sampler moved onto this engine keeps its
draws.
raw docstring

all-settledclj/s

(all-settled executor n start)

Run (start i resolve reject) for i < n together, spread over executor's threads (executor/spread!; on this thread when nil); resolves the results in order, or rejects with the first failure.

Run `(start i resolve reject)` for i < n together, spread over `executor`'s
threads (`executor/spread!`; on this thread when nil); resolves the results
in order, or rejects with the first failure.
sourceraw docstring

executor-ofclj/s

(executor-of trace)
source

log-sum-expclj/s

(log-sum-exp xs)
source

next-deltaclj/s

(next-delta lw ls beta target)

The temperature increment whose conditional ESS is target: the rest of the way to 1 when that keeps it, else by bisection.

The temperature increment whose conditional ESS is `target`: the rest of
the way to 1 when that keeps it, else by bisection.
sourceraw docstring

relative-cessclj/s

(relative-cess lw ls delta)

The conditional ESS of the incremental weights exp(δ·ℓ) under the normalized log weights lw, as a fraction of N.

The conditional ESS of the incremental weights exp(δ·ℓ) under the
normalized log weights `lw`, as a fraction of N.
sourceraw docstring

single-blockclj/s

(single-block ts)

{:address :dist} when every trace in ts is one latent block site and nothing else (no other choice, observation or factor), all under one law: then a particle is its θ, and inference needs no world until the end.

{:address :dist} when every trace in `ts` is one latent block site and
nothing else (no other choice, observation or factor), all under one law:
then a particle is its θ, and inference needs no world until the end.
sourceraw docstring

theta-scalesclj/s

(theta-scales qs scale)

A random walk over θ vectors sized to the population: each coordinate's standard deviation over qs times scale/√dimension.

A random walk over θ vectors sized to the population: each coordinate's
standard deviation over `qs` times `scale`/√dimension.
sourceraw docstring

theta-smcclj/s

(theta-smc qs
           path
           {:keys [n waste-free scale max-steps seed stats keys positions?]
            :or {positions? true}})

An SMC sampler on θ vectors qs along path; returns {:qs :log-z :positions}.

path: :start the first position :done? (fn [pos]) whether pos is the last target :advance (fn [qs lw pos]) -> {:pos pos' :log-incr [w …]}: the next position and every particle's incremental log weight to it :density (fn [pos]) -> the log density of θ the moves at pos leave invariant :exhausted (fn [pos]) -> the exception thrown after :max-steps

opts: :n particles, :waste-free P (resample n/P and keep every state of their P-step chains), :scale of the population random walk, :max-steps, :seed, :stats (an atom counting :moves and :accepted), :keys {:resample k :move k}, the stream keys of step k's resampling ([k-resample k]) and chain i's moves ([k-move k i]), and :positions? (true): false keeps only the last position in :positions.

An SMC sampler on θ vectors `qs` along `path`; returns {:qs :log-z
:positions}.

`path`:
  :start      the first position
  :done?      (fn [pos]) whether `pos` is the last target
  :advance    (fn [qs lw pos]) -> {:pos pos' :log-incr [w …]}: the next
              position and every particle's incremental log weight to it
  :density    (fn [pos]) -> the log density of θ the moves at `pos` leave
              invariant
  :exhausted  (fn [pos]) -> the exception thrown after `:max-steps`

`opts`: `:n` particles, `:waste-free` P (resample n/P and keep every state
of their P-step chains), `:scale` of the population random walk,
`:max-steps`, `:seed`, `:stats` (an atom counting `:moves` and
`:accepted`), `:keys` {:resample k :move k}, the stream keys of step
k's resampling ([k-resample k]) and chain i's moves ([k-move k i]), and
`:positions?` (true): false keeps only the last position in `:positions`.
sourceraw docstring

write-back-allclj/s

(write-back-all template address qs)

Traces of template with the block site at address set to each of qs (one replay per distinct θ); resolves them in order, or rejects when the program fails on one of them.

Traces of `template` with the block site at `address` set to each of `qs`
(one replay per distinct θ); resolves them in order, or rejects when the
program fails on one of them.
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