Liking cljdoc? Tell your friends :D

org.replikativ.foerster.block

Numerical blocks as choice sites (the spindel side of the spindel ↔ raster block contract, spindel-raster doc/contract.md).

A block is a fixed-shape group of latent variables with the density factors they touch, given as a description (data) and capabilities (functions over primitive arrays):

(block {:block/id :gauss :block/latents [{:name :mu :shape [2] :support :real}] :block/target :complete-conditional} {:log-density (fn [^doubles theta inputs] lp) :value+grad (fn [^doubles theta inputs] [lp ^doubles grad])})

(block-dist b inputs) is the block at its inputs as a distribution whose density is the block's log target, so a block site is an ordinary choice site: (sample (block-dist b inputs) :id :mu :init [0.0 0.0]). Its value is θ, the latents flattened in declared order, as a vector of doubles.

The target includes every factor the latents touch: their priors and the observations that depend on them, which must then not be observed again as sites of their own. A block without :sample cannot be drawn from; start it at an :init. :sample need not draw from the target (it cannot know its normalizer); a block drawn from under importance sampling or SMC, or proposed from by single-site MH, also needs :sample-log-density, the log density of what :sample draws, which weighs the draw: log target(θ) − log sample-density(θ).

Draft 0 supports unconstrained real latents only; transforms of constrained ones (:constrain, :unconstrain with their Jacobians) come with raster's bijectors.

Numerical blocks as choice sites (the spindel side of the spindel ↔ raster
block contract, spindel-raster doc/contract.md).

A block is a fixed-shape group of latent variables with the density factors
they touch, given as a description (data) and capabilities (functions over
primitive arrays):

  (block {:block/id :gauss
          :block/latents [{:name :mu :shape [2] :support :real}]
          :block/target :complete-conditional}
         {:log-density (fn [^doubles theta inputs] lp)
          :value+grad  (fn [^doubles theta inputs] [lp ^doubles grad])})

`(block-dist b inputs)` is the block at its inputs as a distribution whose
density is the block's log target, so a block site is an ordinary choice
site: `(sample (block-dist b inputs) :id :mu :init [0.0 0.0])`. Its value is
θ, the latents flattened in declared order, as a vector of doubles.

The target includes every factor the latents touch: their priors and the
observations that depend on them, which must then not be observed again as
sites of their own. A block without `:sample` cannot be drawn from; start
it at an `:init`. `:sample` need not draw from the target (it cannot know
its normalizer); a block drawn from under importance sampling or SMC, or
proposed from by single-site MH, also needs `:sample-log-density`, the log
density of what `:sample` draws, which weighs the draw:
log target(θ) − log sample-density(θ).

Draft 0 supports unconstrained real latents only; transforms of constrained
ones (`:constrain`, `:unconstrain` with their Jacobians) come with raster's
bijectors.
raw docstring

blockclj/s

(block description capabilities)

A block from its description and capabilities (see the namespace).

A block from its `description` and `capabilities` (see the namespace).
sourceraw docstring

block-distclj/s

(block-dist b inputs)

Block b at inputs, as the distribution of its site.

Block `b` at `inputs`, as the distribution of its site.
sourceraw docstring

block-dist?clj/s

(block-dist? d)
source

capabilityclj/s

(capability b k)

The capability k of block b, or nil.

The capability `k` of block `b`, or nil.
sourceraw docstring

dimensionclj/s

(dimension b)

The length of θ.

The length of θ.
sourceraw docstring

latentclj/s

(latent b theta name)

The latent name of θ: a double for a scalar, a vector otherwise.

The latent `name` of θ: a double for a scalar, a vector otherwise.
sourceraw docstring

value+gradclj/s

(value+grad dist theta)

[log target, gradient] of dist (a block-dist) at θ, both from the block's :value+grad; the gradient as a vector.

[log target, gradient] of `dist` (a `block-dist`) at θ, both from the
block's `:value+grad`; the gradient as a vector.
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