Liking cljdoc? Tell your friends :D

org.replikativ.foerster.analysis

The structure of a model, read from its source: which sites it has, what each one reads, and the facts an inference plan can be derived from.

analyze walks the macro-expanded body of a model (a spin form, or the forms inside one) and returns its site graph:

{:sites {n {:kind :latent | :observed | :factor :address [:y i] ; the :id form, symbols are loop variables; ; [:loc line col] for a site without :id :dist {:ctor normal :args [{:form mu :reads #{0} :exact 0} …]} :reads #{0} ; sites its distribution's arguments read :control #{} ; sites that decide whether it runs :loops [2]}} ; enclosing loops, innermost last :loops {2 {:bindings [i] :sites #{1} :carried #{} :kind :plate | :sequential}} ; :carried: its sites a later iteration reads :unknown [{:reason :closure :form …}]}

A site's value reads the sites its arguments were computed from: the analysis follows locals through let, loop, if and calls, over-approximating a call's result as reading everything its arguments read. A loop whose recurring values read none of its own sites runs independent iterations (a plate); otherwise it is sequential. What the walk cannot see — a site in a closure, which the spin macro cannot see either — is listed under :unknown, never guessed.

facts derives from the graph: the support of each site, finite latent sites, plates, conjugate pairs (foerster.conjugate's families, in the form foerster.conjugate would collapse) and Markov blankets. explain prints both.

The structure of a model, read from its source: which sites it has, what
each one reads, and the facts an inference plan can be derived from.

`analyze` walks the macro-expanded body of a model (a `spin` form, or the
forms inside one) and returns its site graph:

  {:sites   {n {:kind :latent | :observed | :factor
                :address [:y i]        ; the :id form, symbols are loop variables;
                                       ; [:loc line col] for a site without :id
                :dist {:ctor normal :args [{:form mu :reads #{0} :exact 0} …]}
                :reads #{0}            ; sites its distribution's arguments read
                :control #{}           ; sites that decide whether it runs
                :loops [2]}}           ; enclosing loops, innermost last
   :loops   {2 {:bindings [i] :sites #{1} :carried #{} :kind :plate | :sequential}}
               ; :carried: its sites a later iteration reads
   :unknown [{:reason :closure :form …}]}

A site's value reads the sites its arguments were computed from: the
analysis follows locals through let, loop, if and calls, over-approximating
a call's result as reading everything its arguments read. A loop whose
recurring values read none of its own sites runs independent iterations (a
plate); otherwise it is sequential. What the walk cannot see — a site in a
closure, which the spin macro cannot see either — is listed under
`:unknown`, never guessed.

`facts` derives from the graph: the support of each site, finite latent
sites, plates, conjugate pairs (`foerster.conjugate`'s families, in the form
`foerster.conjugate` would collapse) and Markov blankets. `explain` prints
both.
raw docstring

analyzecljmacro

(analyze & body)

The site graph of the model body (a spin form or the forms inside one), analyzed where it is written. Locals in scope are its inputs.

The site graph of the model `body` (a `spin` form or the forms inside one),
analyzed where it is written. Locals in scope are its inputs.
sourceraw docstring

analyze-formclj

(analyze-form form)
(analyze-form form {:keys [ns locals] :or {ns *ns*}})

The site graph of a model's body form (see the namespace doc), symbols resolved in ns (default *ns*). locals are the model's inputs: names bound outside the form, which read no site.

The site graph of a model's body `form` (see the namespace doc), symbols
resolved in `ns` (default `*ns*`). `locals` are the model's inputs: names
bound outside the form, which read no site.
sourceraw docstring

childrenclj

(children sites n)

The sites that read site n, or run only depending on it.

The sites that read site `n`, or run only depending on it.
sourceraw docstring

conjugate-familiesclj

Prior constructor → likelihood constructor → [the likelihood argument the parameter must be, exactly; foerster.conjugate family].

Prior constructor → likelihood constructor → [the likelihood argument the
parameter must be, exactly; `foerster.conjugate` family].
sourceraw docstring

continuousclj

source

explainclj

(explain g)

A readable account of the graph g and its facts.

A readable account of the graph `g` and its facts.
sourceraw docstring

factsclj

(facts {:keys [sites loops unknown]})

Facts about the model the graph g describes, as a vector of maps.

Facts about the model the graph `g` describes, as a vector of maps.
sourceraw docstring

graph-ofclj

(graph-of f)

The site graph a model carries, or nil.

The site graph a `model` carries, or nil.
sourceraw docstring

implemented-familiesclj

Families foerster.conjugate implements.

Families `foerster.conjugate` implements.
sourceraw docstring

modelcljmacro

(model args & body)

(fn args (spin body…)), carrying the site graph of body as metadata (graph-of): a model whose structure inference can read.

`(fn args (spin body…))`, carrying the site graph of `body` as metadata
(`graph-of`): a model whose structure inference can read.
sourceraw docstring

supportclj

The support of a distribution, by its constructor in foerster.dist.

The support of a distribution, by its constructor in `foerster.dist`.
sourceraw docstring

walkclj

(walk {:keys [env state] :as st} form)

The value form computes, recording the sites it runs into (:state st).

The value `form` computes, recording the sites it runs into `(:state st)`.
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