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

compute-essclj/s

(compute-ess weights)

Compute effective sample size from normalized weights.

ESS = 1 / sum(w_i^2) for normalized weights

Compute effective sample size from normalized weights.

ESS = 1 / sum(w_i^2) for normalized weights
sourceraw 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

log-mean-expclj/s

(log-mean-exp log-weights)

log of the mean of exp(x_i).

log of the mean of exp(x_i).
sourceraw docstring

log-sum-expclj/s

(log-sum-exp log-weights)

Numerically stable log-sum-exp.

log(sum(exp(x_i))) = log-max + log(sum(exp(x_i - log-max)))

Numerically stable log-sum-exp.

log(sum(exp(x_i))) = log-max + log(sum(exp(x_i - log-max)))
sourceraw docstring

multinomial-resampleclj/s

(multinomial-resample weights n)

n indices drawn independently from the normalized weights.

`n` indices drawn independently from the normalized `weights`.
sourceraw docstring

normalize-log-weightsclj/s

(normalize-log-weights log-weights)

Convert log-weights to normalized linear weights, summing to 1. All weights zero (##-Inf) gives equal weights — a resampling step's choice among particles that are all impossible; measure-stats refuses such a population. ##Inf weights share the mass equally; a NaN weight throws.

Convert log-weights to normalized linear weights, summing to 1. All
weights zero (##-Inf) gives equal weights — a resampling step's choice
among particles that are all impossible; `measure-stats` refuses such a
population. ##Inf weights share the mass equally; a NaN weight throws.
sourceraw docstring

pick-uniformlyclj/s

(pick-uniformly v)

A uniformly chosen element of a vector, drawn through uniform01.

A uniformly chosen element of a vector, drawn through `uniform01`.
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.

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.

log-marginalclj/s

(log-marginal this)

Estimate of log p(observations): the log mean particle weight plus the normalizer of earlier resampling steps.

Estimate of log p(observations): the log mean particle weight plus the
normalizer of earlier resampling steps.

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

resampleclj/s

(resample scheme weights n)

n ancestor indices from the normalized weights by scheme: :systematic (default), :stratified, :residual or :multinomial.

`n` ancestor indices from the normalized `weights` by `scheme`:
`:systematic` (default), `:stratified`, `:residual` or `:multinomial`.
sourceraw docstring

residual-resampleclj/s

(residual-resample weights n)

Residual resampling: ⌊n·wᵢ⌋ copies of each particle, the rest drawn multinomially from the residual weights.

Residual resampling: ⌊n·wᵢ⌋ copies of each particle, the rest drawn
multinomially from the residual weights.
sourceraw docstring

sample-categoricalclj/s

(sample-categorical weights)

One index drawn from normalized weights, through uniform01.

One index drawn from normalized weights, through `uniform01`.
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

stratified-resampleclj/s

(stratified-resample weights n)

Stratified resampling: one uniform draw in each of the n strata [i/n, (i+1)/n). Lower variance than multinomial, never more than systematic's failure modes.

Stratified resampling: one uniform draw in each of the n strata [i/n,
(i+1)/n). Lower variance than multinomial, never more than systematic's
failure modes.
sourceraw docstring

systematic-resampleclj/s

(systematic-resample weights n)

Systematic resampling algorithm from Anglican.

Low-variance resampling for particle filters. weights: normalized weights (sum to 1) n: number of particles to sample

Returns vector of indices into original particle vector.

Systematic resampling algorithm from Anglican.

Low-variance resampling for particle filters.
weights: normalized weights (sum to 1)
n: number of particles to sample

Returns vector of indices into original particle vector.
sourceraw docstring

uniform01clj/s

(uniform01)

One uniform draw from the current generator (foerster.random), so resampling, ancestor choice, the accept step and the site choice of every kernel obey random/set-seed! exactly like the program's samples do. clojure.core/rand did not: it reads Math/random's own unseedable generator, which made a seeded run reproducible in its prior draws and random in its resampling and moves.

One uniform draw from the current generator (`foerster.random`), so
resampling, ancestor choice, the accept step and the site choice of every
kernel obey `random/set-seed!` exactly like the program's samples do.
`clojure.core/rand` did not: it reads `Math/random`'s own unseedable
generator, which made a seeded run reproducible in its prior draws and
random in its resampling and moves.
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