Did you know ... | Search Documentation: |
Pack plrand -- prolog/prob/meta.pl |
This module provides a mini language for describing and sampling from random variables.
sample/2 uses and modifies the global state. sample/4 uses a given random generator state and returns the state on completion, and is designed to compatible with DCG syntax to hide the threading of the random state through several consecutive calls.
DistExpression is an expression describing a distribution. The head functor can be a distribution name (as listed by rv/2) or one of a number of arithmetic operators or term constructors. The arguments (in almost all cases) can then be further DistExpressions which are evaluated recursively. Valid non-distributional termsare:
return samples from X, Y etc in a list
rep(N,X)
returns N independent sample from X in a list (N must be a constant)
factorial(N,X)
returns N independent sample from X in an N argument term \(X1,...,XN)For example
?- sample(invgamma(1)*rep(8,discrete(dirichlet(rep(4,0.5)))),X). X = [3, 2, 3, 3, 3, 1, 2, 2] .
sample/2 uses and modifies the global state. sample/4 uses a given random generator state and returns the state on completion, and is designed to compatible with DCG syntax to hide the threading of the random state through several consecutive calls.
DistExpression is an expression describing a distribution. The head functor can be a distribution name (as listed by rv/2) or one of a number of arithmetic operators or term constructors. The arguments (in almost all cases) can then be further DistExpressions which are evaluated recursively. Valid non-distributional termsare:
return samples from X, Y etc in a list
rep(N,X)
returns N independent sample from X in a list (N must be a constant)
factorial(N,X)
returns N independent sample from X in an N argument term \(X1,...,XN)For example
?- sample(invgamma(1)*rep(8,discrete(dirichlet(rep(4,0.5)))),X). X = [3, 2, 3, 3, 3, 1, 2, 2] .
The following predicates are exported, but not or incorrectly documented.