Liking cljdoc? Tell your friends :D

org.replikativ.foerster.conjugate

Conjugate parameters, carried as posteriors instead of sampled.

A static parameter of a conjugate pair need never be drawn: the program holds its posterior as a value, scores each datum under the posterior predictive and updates the posterior in closed form —

(loop [c (conjugate/beta-bernoulli 1 1) [y & more] ys] (if y (do (observe (conjugate/predictive c) y) (recur (conjugate/update c y) more)) (sample (conjugate/posterior c) :id :p))) ; the parameter, if needed

— which is exact marginalization (Rao-Blackwellization; the conjugate case of delayed sampling, Murray et al. 2018). Under SMC the parameter cannot degenerate, since it is never resampled, and a streaming program pays the same for it at every step. Every operation is a plain function of plain values, so it composes with any foerster program and inference method.

Families: normal-mean (Normal mean with known observation sd), beta-bernoulli, gamma-poisson (Gamma shape and SCALE, as foerster.dist/gamma) and dirichlet-discrete.

Conjugate parameters, carried as posteriors instead of sampled.

A static parameter of a conjugate pair need never be drawn: the program
holds its posterior as a value, scores each datum under the posterior
predictive and updates the posterior in closed form —

  (loop [c (conjugate/beta-bernoulli 1 1) [y & more] ys]
    (if y
      (do (observe (conjugate/predictive c) y)
          (recur (conjugate/update c y) more))
      (sample (conjugate/posterior c) :id :p)))   ; the parameter, if needed

— which is exact marginalization (Rao-Blackwellization; the conjugate case
of delayed sampling, Murray et al. 2018). Under SMC the parameter cannot
degenerate, since it is never resampled, and a streaming program pays the
same for it at every step. Every operation is a plain function of plain
values, so it composes with any foerster program and inference method.

Families: `normal-mean` (Normal mean with known observation sd),
`beta-bernoulli`, `gamma-poisson` (Gamma shape and SCALE, as
`foerster.dist/gamma`) and `dirichlet-discrete`.
raw docstring

beta-bernoulliclj/s

(beta-bernoulli alpha beta)

p ~ Beta(α, β) of observations Bernoulli(p) (0 or 1).

p ~ Beta(α, β) of observations Bernoulli(p) (0 or 1).
sourceraw docstring

dirichlet-discreteclj/s

(dirichlet-discrete alpha)

w ~ Dirichlet(α) of observations discrete(w) (indices 0 … n−1).

w ~ Dirichlet(α) of observations discrete(w) (indices 0 … n−1).
sourceraw docstring

gamma-poissonclj/s

(gamma-poisson shape scale)

λ ~ Gamma(shape, scale) of observations Poisson(λ).

λ ~ Gamma(shape, scale) of observations Poisson(λ).
sourceraw docstring

normal-meanclj/s

(normal-mean mean sd obs-sd)

The mean μ ~ Normal(mean, sd) of observations Normal(μ, obs-sd).

The mean μ ~ Normal(mean, sd) of observations Normal(μ, obs-sd).
sourceraw docstring

posteriorclj/s

(posterior {:keys [family] :as c})

The parameter's posterior distribution.

The parameter's posterior distribution.
sourceraw docstring

predictiveclj/s

(predictive {:keys [family] :as c})

The posterior predictive distribution of the next observation.

The posterior predictive distribution of the next observation.
sourceraw docstring

updateclj/s

(update {:keys [family] :as c} y)

The posterior after observing y.

The posterior after observing `y`.
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