monad-bayes-1.3.0.1: 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

type Sampler = SamplerT Identity 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.

newtype SamplerT m a Source #

Constructors

SamplerT 

Fields

Instances

Instances details
MonadTrans SamplerT Source # 
Instance details

Defined in Control.Monad.Bayes.Sampler.Lazy

Methods

lift :: Monad m => m a -> SamplerT m a #

MonadIO m => MonadIO (SamplerT m) Source # 
Instance details

Defined in Control.Monad.Bayes.Sampler.Lazy

Methods

liftIO :: IO a -> SamplerT m a #

Monad m => Applicative (SamplerT m) Source # 
Instance details

Defined in Control.Monad.Bayes.Sampler.Lazy

Methods

pure :: a -> SamplerT m a #

(<*>) :: SamplerT m (a -> b) -> SamplerT m a -> SamplerT m b #

liftA2 :: (a -> b -> c) -> SamplerT m a -> SamplerT m b -> SamplerT m c #

(*>) :: SamplerT m a -> SamplerT m b -> SamplerT m b #

(<*) :: SamplerT m a -> SamplerT m b -> SamplerT m a #

Functor m => Functor (SamplerT m) Source # 
Instance details

Defined in Control.Monad.Bayes.Sampler.Lazy

Methods

fmap :: (a -> b) -> SamplerT m a -> SamplerT m b #

(<$) :: a -> SamplerT m b -> SamplerT m a #

Monad m => Monad (SamplerT m) Source #

Sequencing is done by splitting the tree and using different bits for different computations.

Instance details

Defined in Control.Monad.Bayes.Sampler.Lazy

Methods

(>>=) :: SamplerT m a -> (a -> SamplerT m b) -> SamplerT m b #

(>>) :: SamplerT m a -> SamplerT m b -> SamplerT m b #

return :: a -> SamplerT m a #

Monad m => MonadDistribution (SamplerT m) Source #

Sampling gets the label at the head of the tree and discards the rest.

Instance details

Defined in Control.Monad.Bayes.Sampler.Lazy

splitTree :: Tree -> (Tree, Tree) Source #

Split a tree in two (bijectively).

randomTree :: RandomGen g => g -> Tree Source #

Generate a tree with uniform random labels.

Preliminary for the simulation methods. This uses split to split a random seed.

runSamplerTIO :: MonadIO m => SamplerT m a -> m a Source #

Runs a SamplerT by creating a new StdGen.

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

Draw a stream of independent samples.

weightedSamples :: MonadIO m => WeightedT (SamplerT m) a -> m [(a, Log Double)] Source #

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