monad-bayes-1.1.0: A library for probabilistic programming.
Copyright(c) Adam Scibior 2015-2020
LicenseMIT
Maintainerleonhard.markert@tweag.io
Stabilityexperimental
PortabilityGHC
Safe HaskellSafe-Inferred
LanguageHaskell2010

Control.Monad.Bayes.Sampler.Strict

Description

SamplerIO and SamplerST are instances of MonadDistribution. Apply a MonadFactor transformer to obtain a MonadMeasure that can execute probabilistic models.

Synopsis

Documentation

data Sampler g m a Source #

The sampling interpretation of a probabilistic program Here m is typically IO or ST

Instances

Instances details
MonadIO m => MonadIO (Sampler g m) Source # 
Instance details

Defined in Control.Monad.Bayes.Sampler.Strict

Methods

liftIO :: IO a -> Sampler g m a #

Applicative m => Applicative (Sampler g m) Source # 
Instance details

Defined in Control.Monad.Bayes.Sampler.Strict

Methods

pure :: a -> Sampler g m a #

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

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

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

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

Functor m => Functor (Sampler g m) Source # 
Instance details

Defined in Control.Monad.Bayes.Sampler.Strict

Methods

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

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

Monad m => Monad (Sampler g m) Source # 
Instance details

Defined in Control.Monad.Bayes.Sampler.Strict

Methods

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

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

return :: a -> Sampler g m a #

StatefulGen g m => MonadDistribution (Sampler g m) Source # 
Instance details

Defined in Control.Monad.Bayes.Sampler.Strict

type SamplerIO = Sampler (IOGenM StdGen) IO Source #

convenient type synonym to show specializations of Sampler to particular pairs of monad and RNG

type SamplerST s = Sampler (STGenM StdGen s) (ST s) Source #

convenient type synonym to show specializations of Sampler to particular pairs of monad and RNG

sampleIO :: SamplerIO a -> IO a Source #

initialize random seed using system entropy, and sample

sampleIOfixed :: SamplerIO a -> IO a Source #

Run the sampler with a fixed random seed

sampleWith :: Sampler g m a -> g -> m a Source #

Sample with a random number generator of your choice e.g. the one from Random.

>>> import Control.Monad.Bayes.Class
>>> import System.Random.Stateful hiding (random)
>>> newIOGenM (mkStdGen 1729) >>= sampleWith random
4.690861245089605e-2

sampleSTfixed :: SamplerST s b -> ST s b Source #

Run the sampler with a fixed random seed

sampler :: SamplerIO a -> IO a Source #

initialize random seed using system entropy, and sample