Liking cljdoc? Tell your friends :D

org.replikativ.foerster.measure

Measure abstraction for probabilistic programming.

Measures represent probability distributions over execution traces. This is the foundation for compositional inference algorithms.

Measure abstraction for probabilistic programming.

Measures represent probability distributions over execution traces.
This is the foundation for compositional inference algorithms.
raw docstring

empiricalclj/s

(empirical particles)

Create an empirical measure from weighted particles.

particles: vector of [context log-weight] pairs

Create an empirical measure from weighted particles.

particles: vector of [context log-weight] pairs
sourceraw docstring

get-contextsclj/s

(get-contexts measure)

Extract execution contexts from measure.

Extract execution contexts from measure.
sourceraw docstring

get-log-weightsclj/s

(get-log-weights measure)

Extract log-weights from measure.

Extract log-weights from measure.
sourceraw docstring

get-particlesclj/s

(get-particles measure)

The particles of measure: a vector of [context log-weight] pairs.

The particles of `measure`: a vector of [context log-weight] pairs.
sourceraw docstring

get-traceclj/s

(get-trace context)

The trace {address -> entry} of a particle (context or Sample).

The trace {address -> entry} of a particle (context or Sample).
sourceraw docstring

get-valueclj/s

(get-value context)

Extract the program result from an execution context (or a Sample).

The result is stored in [:inference :result] after execution completes.

Args: context - ExecutionContext from inference

Returns: The value returned by the probabilistic program

Extract the program result from an execution context (or a Sample).

The result is stored in [:inference :result] after execution completes.

Args:
  context - ExecutionContext from inference

Returns: The value returned by the probabilistic program
sourceraw docstring

markov-measureclj/s

(markov-measure particles)
(markov-measure particles {:keys [estimator log-normalizer]})

Settled chain draws. Their weights combine samples, not evidence estimates, so log-marginal is nil. A chain method that computes a separate evidence estimate (parallel tempering's stepping stones) passes it as normalizer {:estimator e :log-normalizer l}: the contract then names that estimator, status :estimate, and log-marginal returns it. Either way the draws are autocorrelated: their weight-based effective-sample-size is not the chain ESS (see foerster.diagnostics/summary, which uses :chain-lengths).

Settled chain draws. Their weights combine samples, not evidence estimates,
so `log-marginal` is nil. A chain method that computes a separate evidence
estimate (parallel tempering's stepping stones) passes it as `normalizer`
{:estimator e :log-normalizer l}: the contract then names that estimator,
status `:estimate`, and `log-marginal` returns it. Either way the draws are
autocorrelated: their weight-based `effective-sample-size` is not the chain
ESS (see `foerster.diagnostics/summary`, which uses `:chain-lengths`).
sourceraw docstring

PMeasureclj/sprotocol

Protocol for probability measures over execution traces.

A measure represents a distribution over execution contexts (traces); inference resolves an EmpiricalMeasure, a weighted particle set.

Protocol for probability measures over execution traces.

A measure represents a distribution over execution contexts (traces);
inference resolves an EmpiricalMeasure, a weighted particle set.

effective-sample-sizeclj/s

(effective-sample-size this)

Effective sample size (ESS) for particle degeneracy detection.

ESS = (sum w_i)^2 / sum(w_i^2) where w_i are normalized weights. Low ESS indicates degeneracy -> trigger resampling. For Markov-chain draws (equal weights) this is the number of draws, not the chain ESS: use foerster.diagnostics/summary.

Effective sample size (ESS) for particle degeneracy detection.

ESS = (sum w_i)^2 / sum(w_i^2) where w_i are normalized weights.
Low ESS indicates degeneracy -> trigger resampling. For Markov-chain
draws (equal weights) this is the number of draws, not the chain ESS:
use `foerster.diagnostics/summary`.

log-marginalclj/s

(log-marginal this)

Log population mass: log mean weight plus earlier normalizers. Returns nil for explicitly marked chain outputs, which do not estimate evidence. A numerical value alone does not certify its scale or unbiasedness.

Log population mass: log mean weight plus earlier normalizers. Returns nil
for explicitly marked chain outputs, which do not estimate evidence. A
numerical value alone does not certify its scale or unbiasedness.

measure-statsclj/s

(measure-stats this query-fn)

Compute statistics over the measure using query-fn.

query-fn: (fn [context] -> value)

Returns map with :mean, :variance, :quantiles, etc. Useful for extracting posterior statistics.

Compute statistics over the measure using query-fn.

query-fn: (fn [context] -> value)

Returns map with :mean, :variance, :quantiles, etc.
Useful for extracting posterior statistics.

measure-typeclj/s

(measure-type this)

Returns the type of measure: :empirical.

Returns the type of measure: :empirical.

sample-measureclj/s

(sample-measure this n)

Sample n execution contexts from this measure.

Returns vector of [context log-weight] pairs, drawn according to the weights.

Sample n execution contexts from this measure.

Returns vector of [context log-weight] pairs, drawn according to the
weights.
sourceraw docstring

sample-particleclj/s

(sample-particle result trace)

A particle that carries only a program result and its trace — what a pooled MCMC estimate keeps per draw, instead of pinning a context.

A particle that carries only a program result and its trace — what a
pooled MCMC estimate keeps per draw, instead of pinning a context.
sourceraw docstring

site-valueclj/s

(site-value particle address)

The value a particle's site address took: a sample, an observation or a deterministic value.

The value a particle's site `address` took: a sample, an observation or a
`deterministic` value.
sourceraw docstring

weighted-quantilesclj/s

(weighted-quantiles values weights)

A function of p in [0, 1]: the p-quantile of values weighted by the normalized weights, the smallest value whose cumulative weight reaches p.

A function of p in [0, 1]: the p-quantile of `values` weighted by the
normalized `weights`, the smallest value whose cumulative weight reaches p.
sourceraw docstring

world-descriptorsclj/s

(world-descriptors measure)

The world descriptors of measure's particles that ran in canonical worlds (:world-policy :fork), in particle order. Particles of pure inference ran in no such world, and contribute none.

The world descriptors of `measure`'s particles that ran in canonical worlds
(`:world-policy :fork`), in particle order. Particles of pure inference ran
in no such world, and contribute none.
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