API
Part of the API of DynamicPPL is defined in the more lightweight interface package AbstractPPL.jl and reexported here.
Model
Macros
A core component of DynamicPPL is the @model
macro. It can be used to define probabilistic models in an intuitive way by specifying random variables and their distributions with ~
statements. These statements are rewritten by @model
as calls of internal functions for sampling the variables and computing their log densities.
DynamicPPL.@model
— Macro@model(expr[, warn = false])
Macro to specify a probabilistic model.
If warn
is true
, a warning is displayed if internal variable names are used in the model definition.
Examples
Model definition:
@model function model(x, y = 42)
...
end
To generate a Model
, call model(xvalue)
or model(xvalue, yvalue)
.
One can nest models and call another model inside the model function with @submodel
.
DynamicPPL.@submodel
— Macro@submodel model
diff --git a/dev/index.html b/dev/index.html
index 2fd3c0a9a..9c2a6b4bd 100644
--- a/dev/index.html
+++ b/dev/index.html
@@ -457,6 +457,7 @@
});
+
DynamicPPL.jl
A domain-specific language and backend for probabilistic programming languages, used by Turing.jl.
+
Transforming variables
Motivation
In a probabilistic programming language (PPL) such as DynamicPPL.jl, one crucial functionality for enabling a large number of inference algorithms to be implemented, in particular gradient-based ones, is the ability to work with "unconstrained" variables.
For example, consider the following model:
@model function demo()
s ~ InverseGamma(2, 3)
return m ~ Normal(0, √s)