From 376003c026a62456e3e208aeb2bea8dacb58e255 Mon Sep 17 00:00:00 2001 From: "Documenter.jl" Date: Thu, 26 Sep 2024 15:48:41 +0000 Subject: [PATCH] build based on 84c7466 --- index.html | 1 - previews/PR100/.documenter-siteinfo.json | 2 +- previews/PR100/api/index.html | 475 +---------------------- previews/PR100/index.html | 461 +--------------------- 4 files changed, 10 insertions(+), 929 deletions(-) diff --git a/index.html b/index.html index 83aa121..1a6cc11 100644 --- a/index.html +++ b/index.html @@ -1,3 +1,2 @@ - diff --git a/previews/PR100/.documenter-siteinfo.json b/previews/PR100/.documenter-siteinfo.json index ca6c2b0..c793c3f 100644 --- a/previews/PR100/.documenter-siteinfo.json +++ b/previews/PR100/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.10.5","generation_timestamp":"2024-09-26T15:46:52","documenter_version":"1.7.0"}} \ No newline at end of file +{"documenter":{"julia_version":"1.10.5","generation_timestamp":"2024-09-26T15:48:37","documenter_version":"1.7.0"}} \ No newline at end of file diff --git a/previews/PR100/api/index.html b/previews/PR100/api/index.html index abb6447..b491fa1 100644 --- a/previews/PR100/api/index.html +++ b/previews/PR100/api/index.html @@ -1,478 +1,20 @@ -API · AbstractPPL - - - - - -

API

VarNames

AbstractPPL.VarNameType
VarName{sym}(optic=identity)

A variable identifier for a symbol sym and optic optic.

The Julia variable in the model corresponding to sym can refer to a single value or to a hierarchical array structure of univariate, multivariate or matrix variables. The field lens stores the indices requires to access the random variable from the Julia variable indicated by sym as a tuple of tuples. Each element of the tuple thereby contains the indices of one optic operation.

VarNames can be manually constructed using the VarName{sym}(optic) constructor, or from an optic expression through the @varname convenience macro.

Examples

julia> vn = VarName{:x}(Accessors.IndexLens((Colon(), 1)) ⨟ Accessors.IndexLens((2, )))
+API · AbstractPPL

API

VarNames

AbstractPPL.VarNameType
VarName{sym}(optic=identity)

A variable identifier for a symbol sym and optic optic.

The Julia variable in the model corresponding to sym can refer to a single value or to a hierarchical array structure of univariate, multivariate or matrix variables. The field lens stores the indices requires to access the random variable from the Julia variable indicated by sym as a tuple of tuples. Each element of the tuple thereby contains the indices of one optic operation.

VarNames can be manually constructed using the VarName{sym}(optic) constructor, or from an optic expression through the @varname convenience macro.

Examples

julia> vn = VarName{:x}(Accessors.IndexLens((Colon(), 1)) ⨟ Accessors.IndexLens((2, )))
 x[:, 1][2]
 
 julia> getoptic(vn)
 (@o _[Colon(), 1][2])
 
 julia> @varname x[:, 1][1+1]
-x[:, 1][2]
source
AbstractPPL.getsymFunction
getsym(vn::VarName)

Return the symbol of the Julia variable used to generate vn.

Examples

julia> getsym(@varname(x[1][2:3]))
+x[:, 1][2]
source
AbstractPPL.getsymFunction
getsym(vn::VarName)

Return the symbol of the Julia variable used to generate vn.

Examples

julia> getsym(@varname(x[1][2:3]))
 :x
 
 julia> getsym(@varname(y))
-:y
source
AbstractPPL.getopticFunction
getoptic(vn::VarName)

Return the optic of the Julia variable used to generate vn.

Examples

julia> getoptic(@varname(x[1][2:3]))
+:y
source
AbstractPPL.getopticFunction
getoptic(vn::VarName)

Return the optic of the Julia variable used to generate vn.

Examples

julia> getoptic(@varname(x[1][2:3]))
 (@o _[1][2:3])
 
 julia> getoptic(@varname(y))
-identity (generic function with 1 method)
source
AbstractPPL.inspaceFunction
inspace(vn::Union{VarName, Symbol}, space::Tuple)

Check whether vn's variable symbol is in space. The empty tuple counts as the "universal space" containing all variables. Subsumption (see subsumes) is respected.

Examples

julia> inspace(@varname(x[1][2:3]), ())
+identity (generic function with 1 method)
source
AbstractPPL.inspaceFunction
inspace(vn::Union{VarName, Symbol}, space::Tuple)

Check whether vn's variable symbol is in space. The empty tuple counts as the "universal space" containing all variables. Subsumption (see subsumes) is respected.

Examples

julia> inspace(@varname(x[1][2:3]), ())
 true
 
 julia> inspace(@varname(x[1][2:3]), (:x,))
@@ -488,7 +30,7 @@
 true
 
 julia> inspace(@varname(x[1][2:3]), (@varname(x[1:10]),))
-true
source
AbstractPPL.subsumesFunction
subsumes(u::VarName, v::VarName)

Check whether the variable name v describes a sub-range of the variable u. Supported indexing:

  • Scalar:

```jldoctest julia> subsumes(@varname(x), @varname(x[1, 2])) true

julia> subsumes(@varname(x[1, 2]), @varname(x[1, 2][3])) true ```

  • Array of scalar: basically everything that fulfills issubset.

```jldoctest julia> subsumes(@varname(x[[1, 2], 3]), @varname(x[1, 3])) true

julia> subsumes(@varname(x[1:3]), @varname(x[2][1])) true ```

  • Slices:

jldoctest julia> subsumes(@varname(x[2, :]), @varname(x[2, 10][1])) true

Currently not supported are:

  • Boolean indexing, literal CartesianIndex (these could be added, though)
  • Linear indexing of multidimensional arrays: x[4] does not subsume x[2, 2] for a matrix x
  • Trailing ones: x[2, 1] does not subsume x[2] for a vector x
source
AbstractPPL.@varnameMacro
@varname(expr, concretize=false)

A macro that returns an instance of VarName given a symbol or indexing expression expr.

If concretize is true, the resulting expression will be wrapped in a concretize() call.

Note that expressions involving dynamic indexing, i.e. begin and/or end, will always need to be concretized as VarName only supports non-dynamic indexing as determined by is_static_optic. See examples below.

Examples

Dynamic indexing

julia> x = (a = [1.0 2.0; 3.0 4.0; 5.0 6.0], );
+true
source
AbstractPPL.subsumesFunction
subsumes(u::VarName, v::VarName)

Check whether the variable name v describes a sub-range of the variable u. Supported indexing:

  • Scalar:

```jldoctest julia> subsumes(@varname(x), @varname(x[1, 2])) true

julia> subsumes(@varname(x[1, 2]), @varname(x[1, 2][3])) true ```

  • Array of scalar: basically everything that fulfills issubset.

```jldoctest julia> subsumes(@varname(x[[1, 2], 3]), @varname(x[1, 3])) true

julia> subsumes(@varname(x[1:3]), @varname(x[2][1])) true ```

  • Slices:

jldoctest julia> subsumes(@varname(x[2, :]), @varname(x[2, 10][1])) true

Currently not supported are:

  • Boolean indexing, literal CartesianIndex (these could be added, though)
  • Linear indexing of multidimensional arrays: x[4] does not subsume x[2, 2] for a matrix x
  • Trailing ones: x[2, 1] does not subsume x[2] for a vector x
source
AbstractPPL.@varnameMacro
@varname(expr, concretize=false)

A macro that returns an instance of VarName given a symbol or indexing expression expr.

If concretize is true, the resulting expression will be wrapped in a concretize() call.

Note that expressions involving dynamic indexing, i.e. begin and/or end, will always need to be concretized as VarName only supports non-dynamic indexing as determined by is_static_optic. See examples below.

Examples

Dynamic indexing

julia> x = (a = [1.0 2.0; 3.0 4.0; 5.0 6.0], );
 
 julia> @varname(x.a[1:end, end][:], true)
 x.a[1:3, 2][:]
@@ -542,14 +84,14 @@
 a.x[1]
 
 julia> @varname(b.$name.x[1])
-b.a.x[1]
source
AbstractPPL.@vsymMacro
@vsym(expr)

A macro that returns the variable symbol given the input variable expression expr. For example, @vsym x[1] returns :x.

Examples

julia> @vsym x
+b.a.x[1]
source
AbstractPPL.@vsymMacro
@vsym(expr)

A macro that returns the variable symbol given the input variable expression expr. For example, @vsym x[1] returns :x.

Examples

julia> @vsym x
 :x
 
 julia> @vsym x[1,1][2,3]
 :x
 
 julia> @vsym x[end]
-:x
source
AbstractPPL.vn_to_stringFunction
vn_to_string(vn::VarName)

Convert a VarName as a string, via an intermediate named tuple. This differs from string(vn) in that concretised slices are faithfully represented (rather than being pretty-printed as colons).

julia> vn_to_string(@varname(x))
+:x
source
AbstractPPL.vn_to_stringFunction
vn_to_string(vn::VarName)

Convert a VarName as a string, via an intermediate named tuple. This differs from string(vn) in that concretised slices are faithfully represented (rather than being pretty-printed as colons).

julia> vn_to_string(@varname(x))
 "(sym = \"x\", optic = (type = \"identity\",))"
 
 julia> vn_to_string(@varname(x.a))
@@ -559,5 +101,4 @@
 "(sym = \"y\", optic = (type = \"index\", indices = \"(:,)\"))"
 
 julia> y = ones(2); vn_to_string(@varname(y[:], true))
-"(sym = \"y\", optic = (type = \"index\", indices = \"(ConcretizedSlice(Base.OneTo(2)),)\"))"
source
AbstractPPL.vn_from_stringFunction
vn_from_string(str)

Convert a string representation of a VarName back to a VarName. The string should have been generated by vn_to_string.

Warning

This function should only be used with trusted input, as it uses eval

and Meta.parse to parse the string.

source

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

- +"(sym = \"y\", optic = (type = \"index\", indices = \"(ConcretizedSlice(Base.OneTo(2)),)\"))"
source
AbstractPPL.vn_from_stringFunction
vn_from_string(str)

Convert a string representation of a VarName back to a VarName. The string should have been generated by vn_to_string.

Warning

This function should only be used with trusted input, as it uses eval

and Meta.parse to parse the string.

source

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

diff --git a/previews/PR100/index.html b/previews/PR100/index.html index 55ca455..1c2623b 100644 --- a/previews/PR100/index.html +++ b/previews/PR100/index.html @@ -1,461 +1,2 @@ -Home · AbstractPPL - - - - - -

AbstractPPL.jl

A lightweight package containing interfaces and associated APIs for modelling languages for probabilistic programming.

- +Home · AbstractPPL

AbstractPPL.jl

A lightweight package containing interfaces and associated APIs for modelling languages for probabilistic programming.