Probabilistic programming API

Abstract model functions

AbstractPPL.conditionFunction
condition(model, observations)

Condition the generative model model on some observed data, creating a new model of the (possibly unnormalized) posterior distribution over them.

observations can be of any supported internal trace type, or a fixed probability expression.

The invariant

m = decondition(condition(m, obs))

should hold for generative models m and arbitrary obs.

source
AbstractPPL.deconditionFunction
decondition(conditioned_model)

Remove the conditioning (i.e., observation data) from conditioned_model, turning it into a generative model over prior and observed variables.

The invariant

m == condition(decondition(m), obs)

should hold for models m with conditioned variables obs.

source
AbstractPPL.fixFunction
fix(model, params)

Fix the values of parameters specified in params within the probabilistic model model. This operation is equivalent to treating the fixed parameters as being drawn from a point mass distribution centered at the values specified in params. Thus these parameters no longer contribute to the accumulated log density.

Conceptually, this is similar to Pearl's do-operator in causal inference, where we intervene on variables by setting them to specific values, effectively cutting off their dependencies on their usual causes in the model.

The invariant

m == unfix(fix(m, params))

should hold for any model m and parameters params.

source
AbstractPPL.unfixFunction
unfix(model)

Remove any fixed parameters from the model model, returning a new model without the fixed parameters.

This function reverses the effect of fix by removing parameter constraints that were previously set. It returns a new model where all previously fixed parameters are allowed to vary according to their original distributions in the model.

The invariant

m == unfix(fix(m, params))

should hold for any model m and parameters params.

source
DensityInterface.logdensityofFunction
logdensityof(model, trace)

Evaluate the (possibly unnormalized) density of the model specified by the probabilistic program in model, at specific values for the random variables given through trace.

trace can be of any supported internal trace type, or a fixed probability expression.

logdensityof should interact with conditioning and deconditioning in the way required by probability theory.

source

Abstract traces