monad-bayes-1.1.0: A library for probabilistic programming.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Control.Monad.Bayes.Sampler.Lazy

Description

This is a port of the implementation of LazyPPL: https://lazyppl.bitbucket.io/

Synopsis

Documentation

data Tree Source #

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.

Constructors

Tree 

data Trees Source #

An infinite stream of Trees.

Constructors

Trees 

Fields

newtype Sampler a Source #

A probability distribution over a is | a function 'Tree -> a' | The idea is that it uses up bits of the tree as it runs

Constructors

Sampler 

Fields

Instances

Instances details
Applicative Sampler Source # 
Instance details

Defined in Control.Monad.Bayes.Sampler.Lazy

Methods

pure :: a -> Sampler a #

(<*>) :: Sampler (a -> b) -> Sampler a -> Sampler b #

liftA2 :: (a -> b -> c) -> Sampler a -> Sampler b -> Sampler c #

(*>) :: Sampler a -> Sampler b -> Sampler b #

(<*) :: Sampler a -> Sampler b -> Sampler a #

Functor Sampler Source # 
Instance details

Defined in Control.Monad.Bayes.Sampler.Lazy

Methods

fmap :: (a -> b) -> Sampler a -> Sampler b #

(<$) :: a -> Sampler b -> Sampler a #

Monad Sampler Source #

probabilities for a monad. | Sequencing is done by splitting the tree | and using different bits for different computations.

Instance details

Defined in Control.Monad.Bayes.Sampler.Lazy

Methods

(>>=) :: Sampler a -> (a -> Sampler b) -> Sampler b #

(>>) :: Sampler a -> Sampler b -> Sampler b #

return :: a -> Sampler a #

MonadDistribution Sampler Source # 
Instance details

Defined in Control.Monad.Bayes.Sampler.Lazy

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

independent :: Monad m => m a -> m [a] Source #

weightedsamples :: Weighted Sampler a -> IO [(a, Log Double)] Source #

weightedsamples runs a probability measure and gets out a stream of (result,weight) pairs