Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
This is a port of the implementation of LazyPPL: https://lazyppl.bitbucket.io/
Synopsis
- data Tree = Tree {}
- data Trees = Trees {}
- newtype SamplerT a = SamplerT {
- runSamplerT :: Tree -> a
- splitTree :: Tree -> (Tree, Tree)
- randomTree :: RandomGen g => g -> Tree
- randomTrees :: RandomGen g => g -> Trees
- sampler :: SamplerT a -> IO a
- independent :: Monad m => m a -> m [a]
- weightedsamples :: WeightedT SamplerT a -> IO [(a, Log Double)]
Documentation
A Tree
is a lazy, infinitely wide and infinitely deep tree, labelled by Doubles
| Our source of randomness will be a Tree, populated by uniform [0,1] choices for each label.
| Often people just use a list or stream instead of a tree.
| But a tree allows us to be lazy about how far we are going all the time.
A probability distribution over a is | a function 'Tree -> a' | The idea is that it uses up bits of the tree as it runs
SamplerT | |
|
Instances
Applicative SamplerT Source # | |
Functor SamplerT Source # | |
Monad SamplerT Source # | probabilities for a monad. | Sequencing is done by splitting the tree | and using different bits for different computations. |
MonadDistribution SamplerT Source # | |
Defined in Control.Monad.Bayes.Sampler.Lazy random :: SamplerT Double Source # uniform :: Double -> Double -> SamplerT Double Source # normal :: Double -> Double -> SamplerT Double Source # gamma :: Double -> Double -> SamplerT Double Source # beta :: Double -> Double -> SamplerT Double Source # bernoulli :: Double -> SamplerT Bool Source # categorical :: Vector v Double => v Double -> SamplerT Int Source # logCategorical :: (Vector v (Log Double), Vector v Double) => v (Log Double) -> SamplerT Int Source # uniformD :: [a] -> SamplerT a Source # geometric :: Double -> SamplerT Int Source # poisson :: Double -> SamplerT Int Source # dirichlet :: Vector v Double => v Double -> SamplerT (v Double) Source # |
splitTree :: Tree -> (Tree, Tree) Source #
Two key things to do with trees: | Split tree splits a tree in two (bijectively) | Get the label at the head of the tree and discard the rest
randomTree :: RandomGen g => g -> Tree Source #
Preliminaries for the simulation methods. Generate a tree with uniform random labels. This uses split
to split a random seed
randomTrees :: RandomGen g => g -> Trees Source #
independent :: Monad m => m a -> m [a] Source #
weightedsamples :: WeightedT SamplerT a -> IO [(a, Log Double)] Source #
weightedsamples
runs a probability measure and gets out a stream of (result,weight) pairs