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/PR776/api/index.html b/previews/PR776/api/index.html index 7dbb4e0de..62644a385 100644 --- a/previews/PR776/api/index.html +++ b/previews/PR776/api/index.html @@ -1,5 +1,462 @@ 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

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}
     f::F
@@ -1375,7 +1832,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
@@ -1542,3 +1998,4 @@
     theme: "neutral"
 });
 
+ diff --git a/previews/PR776/index.html b/previews/PR776/index.html index 3084df8d9..55164cc79 100644 --- a/previews/PR776/index.html +++ b/previews/PR776/index.html @@ -1,7 +1,465 @@ Home · DynamicPPL

DynamicPPL.jl

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

+ mermaid.initialize({ startOnLoad: true, theme: "neutral" });
+ diff --git a/previews/PR776/internals/transformations/index.html b/previews/PR776/internals/transformations/index.html index d830f0f78..d0acd8b28 100644 --- a/previews/PR776/internals/transformations/index.html +++ b/previews/PR776/internals/transformations/index.html @@ -1,5 +1,462 @@ 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 +639,4 @@
     theme: "neutral"
 });
 
+ diff --git a/previews/PR776/internals/varinfo/index.html b/previews/PR776/internals/varinfo/index.html index 32045411f..2c398a7e5 100644 --- a/previews/PR776/internals/varinfo/index.html +++ b/previews/PR776/internals/varinfo/index.html @@ -1,5 +1,462 @@ Design of VarInfo · DynamicPPL

Design of VarInfo

VarInfo is a fairly simple structure.

DynamicPPL.VarInfoType
struct VarInfo{Tmeta, Tlogp} <: AbstractVarInfo
+
+
+
+
+
     metadata::Tmeta
     logp::Base.RefValue{Tlogp}
     num_produce::Base.RefValue{Int}
@@ -174,3 +631,4 @@
     theme: "neutral"
 });
 
+