-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Parallel code generation for hierarchical Bayesian modeling. -- -- Passage is a PArallel SAmpler GEnerator. The user specifies a -- hierarchical Bayesian model and data using the Passage EDSL, and -- Passage generates code to sample the posterior distribution in -- parallel. -- -- Currently Passage targets C with OpenMP threads. @package passage @version 0.1 module Language.Passage.Distribution logit :: Floating a => a -> a logBeta :: Expr -> Expr -> Expr logFact :: Expr -> Expr logComb :: Expr -> Expr -> Expr -- | A normal distribution with mean 0 and precision 1 stdNormal :: Distribution -- | A normal distribution, with a mean and precision normal :: Expr -> Expr -> Distribution standardUniform :: Distribution uniform :: Expr -> Expr -> Distribution discreteUniform :: Expr -> Distribution geometric :: Expr -> Distribution -- | A categorical distribution with given support size and probabilities | -- Probabilities are assumed to add to one (not checked here) categorical :: Expr -> [Expr] -> Distribution -- | A Bernoulli distribution with a mean bernoulli :: Expr -> Distribution -- | A binomial distribution with given number of samples and probability -- of success | Number of samples is assumed to be fixed binomial :: Expr -> Expr -> Distribution negBinomial :: Expr -> Expr -> Distribution poisson :: Expr -> Distribution -- | A beta distribution with the given prior sample sizes. beta :: Expr -> Expr -> Distribution -- | A gamma distribution with the given prior sample sizes. dgamma :: Expr -> Expr -> Distribution -- | An improper uniform distribution; has no impact on likelihood improperUniform :: Distribution -- | An improper scale improperScale :: Distribution module Language.Passage.UI -- | A normal distribution, with a mean and precision normal :: Expr -> Expr -> BayesianNetwork Expr standardUniform :: BayesianNetwork Expr uniform :: Expr -> Expr -> BayesianNetwork Expr -- | A Bernoulli distribution with a mean bernoulli :: Expr -> BayesianNetwork Expr -- | A beta distribution with the given prior sample sizes. beta :: Expr -> Expr -> BayesianNetwork Expr -- | A gamma distribution with the given prior sample sizes. dgamma :: Expr -> Expr -> BayesianNetwork Expr -- | A chi-square distribution with the given degrees of freedom. chiSquare :: Expr -> BayesianNetwork Expr -- | An exponential distribution with the given rate (inverse scale) dexp :: Expr -> BayesianNetwork Expr -- | A Student's T distribution, given the degrees of freedom. studentT :: Expr -> BayesianNetwork Expr symDirichlet :: Int -> Expr -> BayesianNetwork [Expr] -- | An improper uniform distribution; has no impact on likelihood improperUniform :: BayesianNetwork Expr improperScale :: BayesianNetwork Expr module Language.Passage data BayesianNetwork a -- | A Bayesian Network is a collection of stochastic nodes. Stochastic -- nodes may be (optionally) grouped into arrays. data BayesianGraph BayesianGraph :: !IntMap StoVar -> !IntMap ArrayInfo -> BayesianGraph stoNodes :: BayesianGraph -> !IntMap StoVar stoArryas :: BayesianGraph -> !IntMap ArrayInfo -- | A Stochastic variable. data StoVar StoVar :: StoVarName -> PriorInfo -> !Map Expr Expr -> StoVar stoVarName :: StoVar -> StoVarName stoVarPrior :: StoVar -> PriorInfo -- | 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). stoPostDistLL :: StoVar -> !Map Expr Expr type Node = Expr data BayesianSimulator a logGamma :: Term a -> Term a using :: Distribution -> BayesianNetwork Expr tconst :: Double -> Term a -- | Create a 1D vector vector :: (Int, Int) -> (Int -> BayesianNetwork Expr) -> BayesianNetwork ([Expr] -> Expr) -- | Create a 2D matrix matrix :: (Int, Int) -> (Int, Int) -> ([Int] -> BayesianNetwork Expr) -> BayesianNetwork ([Expr] -> Expr) -- | Create an >= 3D array nodeArray :: [(Int, Int)] -> ([Int] -> BayesianNetwork Expr) -> BayesianNetwork ([Expr] -> Expr) type Vector = [Expr] -> Expr type Matrix = [Expr] -> Expr type NodeArray = [Expr] -> Expr tcase :: Term a -> [Term a] -> Term a (//) :: BayesianNetwork Expr -> String -> BayesianNetwork Expr buildBayesianGraph :: BayesianNetwork a -> (a, BayesianGraph) -- | Pretty printing class Show t => PP t ppPrec :: PP t => Rational -> t -> Doc pp :: PP t => t -> Doc class LaTeX t latex :: LaTeX t => t -> Doc simulate :: FilePath -> BayesianSimulator () -> IO () genSimulator :: FilePath -> BayesianSimulator () -> IO () setSampleCount :: Int -> BayesianSimulator () setIterationsPerSample :: Int -> BayesianSimulator () setWarmupCount :: Int -> BayesianSimulator () setThreadNum :: Int -> BayesianSimulator () useMersenneTwister :: Bool -> BayesianSimulator () enableProfiling :: Bool -> BayesianSimulator () -- | 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. setRandomSeed :: Int -> BayesianSimulator () -- | 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. useSpecialSlicers :: Bool -> BayesianSimulator () -- | 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. splitFiles :: Bool -> BayesianSimulator () model :: BayesianNetwork a -> BayesianSimulator a observe :: Term NodeIdx -> Double -> BayesianSimulator () monitor :: String -> Expr -> BayesianSimulator () -- | Like monitor, but adds the indexes in the label of the variable. monitorVec :: String -> Matrix -> [Int] -> BayesianSimulator () monitorVecs :: String -> NodeArray -> [[Int]] -> BayesianSimulator () runLatex :: BayesianNetwork a -> IO ()