diff --git a/dev/api/index.html b/dev/api/index.html index cdccfded9..5017ec279 100644 --- a/dev/api/index.html +++ b/dev/api/index.html @@ -1,5 +1,463 @@ -API · DynamicPPL

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.@modelMacro
@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)
+API · DynamicPPL
+
+
+
+
+
+

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.@modelMacro
@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).

source

One can nest models and call another model inside the model function with @submodel.

DynamicPPL.@submodelMacro
@submodel model
 @submodel ... = model

Run a Turing model nested inside of a Turing model.

Examples

julia> @model function demo1(x)
@@ -1314,7 +1772,6 @@
 julia> # Extract one with only `m`.
        varinfo_subset1 = subset(varinfo, [@varname(m),]);
 
-
 julia> keys(varinfo_subset1)
 1-element Vector{VarName{:m, typeof(identity)}}:
  m
@@ -1452,3 +1909,4 @@
     theme: "neutral"
 });
 
+ diff --git a/dev/index.html b/dev/index.html index 51ced6523..c390833ff 100644 --- a/dev/index.html +++ b/dev/index.html @@ -1,7 +1,466 @@ -Home · DynamicPPL

DynamicPPL.jl

A domain-specific language and backend for probabilistic programming languages, used by Turing.jl.

+ + + + + +

DynamicPPL.jl

A domain-specific language and backend for probabilistic programming languages, used by Turing.jl.

+ diff --git a/dev/internals/transformations/index.html b/dev/internals/transformations/index.html index 1b5016104..bdd5261c7 100644 --- a/dev/internals/transformations/index.html +++ b/dev/internals/transformations/index.html @@ -1,5 +1,463 @@ -Transforming variables · DynamicPPL

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()
+Transforming variables · DynamicPPL
+
+
+
+
+
+

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)
 end

Here we have two variables s and m, where s is constrained to be positive, while m can be any real number.

For certain inference methods, it's necessary / much more convenient to work with an equivalent model to demo but where all the variables can take any real values (they're "unconstrained").

Note

We write "unconstrained" with quotes because there are many ways to transform a constrained variable to an unconstrained one, and DynamicPPL can work with a much broader class of bijective transformations of variables, not just ones that go to the entire real line. But for MCMC, unconstraining is the most common transformation so we'll stick with that terminology.

For a large family of constraints encountered in practice, it is indeed possible to transform a (partially) constrained model to a completely unconstrained one in such a way that sampling in the unconstrained space is equivalent to sampling in the constrained space.

In DynamicPPL.jl, this is often referred to as linking (a term originating in the statistics literature) and is done using transformations from Bijectors.jl.

For example, the above model could be transformed into (the following pseudo-code; it's not working code):

@model function demo()
@@ -182,3 +640,4 @@
     theme: "neutral"
 });
 
+ diff --git a/dev/internals/varinfo/index.html b/dev/internals/varinfo/index.html index b3911acd5..894047c7f 100644 --- a/dev/internals/varinfo/index.html +++ b/dev/internals/varinfo/index.html @@ -1,5 +1,463 @@ -Design of VarInfo · DynamicPPL

Design of VarInfo

VarInfo is a fairly simple structure.

DynamicPPL.VarInfoType
struct VarInfo{Tmeta, Tlogp} <: AbstractVarInfo
+Design of VarInfo · DynamicPPL
+
+
+
+
+
+
+ diff --git a/index.html b/index.html index 6a5afc301..3ac259691 100644 --- a/index.html +++ b/index.html @@ -1,2 +1,3 @@ + diff --git a/previews/PR696/api/index.html b/previews/PR696/api/index.html index 722843174..50d35b9d4 100644 --- a/previews/PR696/api/index.html +++ b/previews/PR696/api/index.html @@ -457,6 +457,7 @@ }); +

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.@modelMacro
@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).

source

Type

A Model can be created by calling the model function, as defined by @model.

DynamicPPL.ModelType
struct Model{F,argnames,defaultnames,missings,Targs,Tdefaults,Ctx<:AbstactContext}
diff --git a/previews/PR696/index.html b/previews/PR696/index.html
index 185d73156..ef71de6fb 100644
--- a/previews/PR696/index.html
+++ b/previews/PR696/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)
diff --git a/previews/PR696/internals/varinfo/index.html b/previews/PR696/internals/varinfo/index.html
index 38d39c656..951f97534 100644
--- a/previews/PR696/internals/varinfo/index.html
+++ b/previews/PR696/internals/varinfo/index.html
@@ -457,6 +457,7 @@
     });
 
 
+