passage-0.1: Parallel code generation for hierarchical Bayesian modeling.

Language.Passage

Synopsis

# Types

Instances

A Bayesian Network is a collection of stochastic nodes. Stochastic nodes may be (optionally) grouped into arrays.

Constructors

 BayesianGraph FieldsstoNodes :: !(IntMap StoVar) stoArryas :: !(IntMap ArrayInfo)

Instances

 Show BayesianGraph PP BayesianGraph LaTeX BayesianGraph

data StoVar Source

A Stochastic variable.

Constructors

 StoVar FieldsstoVarName :: StoVarName stoVarPrior :: PriorInfo stoPostDistLL :: !(Map Expr Expr)Maps terms that mention the variable to their coefficients, which do not depend on the variable. The term for the distribution is the sum of the products of the map elements (see `stoPostLL`).

Instances

 Show StoVar

type Node = ExprSource

Instances

# Constructing models

logGamma :: Term a -> Term aSource

using :: Distribution -> BayesianNetwork ExprSource

tconst :: Double -> Term aSource

Arguments

 :: (Int, Int) Bounds for the vector indexes -> (Int -> BayesianNetwork Expr) Initializer (should return a node) -> BayesianNetwork ([Expr] -> Expr)

Create a 1D vector

Arguments

 :: (Int, Int) -> (Int, Int) Bounds for 1st and 2nd dimensions. -> ([Int] -> BayesianNetwork Expr) Initializer -> BayesianNetwork ([Expr] -> Expr)

Create a 2D matrix

Arguments

 :: [(Int, Int)] Bounds for each dimension. -> ([Int] -> BayesianNetwork Expr) Initializer -> BayesianNetwork ([Expr] -> Expr)

Create an >= 3D array

type Vector = [Expr] -> ExprSource

type Matrix = [Expr] -> ExprSource

type NodeArray = [Expr] -> ExprSource

tcase :: Term a -> [Term a] -> Term aSource

# Displayihng graphs

class Show t => PP t whereSource

Pretty printing

Methods

ppPrec :: Rational -> t -> DocSource

pp :: t -> DocSource

Instances

 PP Char PP Double PP Int PP Integer PP Word PP Op PP BayesianGraph PP PPVar PP a => PP (Term a)

class LaTeX t whereSource

Methods

latex :: t -> DocSource

Instances

 LaTeX Double LaTeX Int LaTeX BayesianGraph LaTeX PPVar LaTeX a => LaTeX (Term a)

# Simulation

Set the random seed for a thread. This function may be calledd multiple times to set the seeds for multiple threads. The seeds are used in order: first call is for thread 0, next for thread 1, etc.

When using a specialized slizer, we generate a custom slicer for each stochastic variable. The benefit of this is that, in principle, this may result in more efficient code, at the cost of longer compilation time, and larger binary. The alternative is to use a generic slicing function which is parameterized by the log-likelihood function for a variable.

Generate a separate file for each stochastic variable. The benefit of this flag is that it makes it possible to compile multiple files in parallel. The drawback is that some optimizations may be lost because the files are compiled separately. Also, there is some overhead for processing multiple files.

Like monitor, but adds the indexes in the label of the variable.