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

Language.Passage

Contents

Synopsis

Types

data BayesianGraph Source

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

Constructors

BayesianGraph 

Fields

stoNodes :: !(IntMap StoVar)
 
stoArryas :: !(IntMap ArrayInfo)
 

data StoVar Source

A Stochastic variable.

Constructors

StoVar 

Fields

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

type Node = ExprSource

Constructing models

logGamma :: Term a -> Term aSource

using :: Distribution -> BayesianNetwork ExprSource

tconst :: Double -> Term aSource

vectorSource

Arguments

:: (Int, Int)

Bounds for the vector indexes

-> (Int -> BayesianNetwork Expr)

Initializer (should return a node)

-> BayesianNetwork ([Expr] -> Expr) 

Create a 1D vector

matrixSource

Arguments

:: (Int, Int) 
-> (Int, Int)

Bounds for 1st and 2nd dimensions.

-> ([Int] -> BayesianNetwork Expr)

Initializer

-> BayesianNetwork ([Expr] -> Expr) 

Create a 2D matrix

nodeArraySource

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

Distributions

Extracting graphs

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

Simulation

setRandomSeed :: Int -> BayesianSimulator ()Source

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.

useSpecialSlicers :: Bool -> BayesianSimulator ()Source

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.

splitFiles :: Bool -> BayesianSimulator ()Source

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.

monitorVec :: String -> Matrix -> [Int] -> BayesianSimulator ()Source

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

LaTeX