Copyright | (c) Adam Scibior 2015-2020 |
---|---|
License | MIT |
Maintainer | leonhard.markert@tweag.io |
Stability | experimental |
Portability | GHC |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
SamplerIO
and SamplerST
are instances of MonadDistribution
. Apply a MonadFactor
transformer to obtain a MonadMeasure
that can execute probabilistic models.
Synopsis
- newtype SamplerT g m a = SamplerT {
- runSamplerT :: ReaderT g m a
- type SamplerIO = SamplerT (IOGenM StdGen) IO
- type SamplerST s = SamplerT (STGenM StdGen s) (ST s)
- sampleIO :: SamplerIO a -> IO a
- sampleIOfixed :: SamplerIO a -> IO a
- sampleWith :: SamplerT g m a -> g -> m a
- sampleSTfixed :: SamplerST s b -> ST s b
- sampleMean :: [(Double, Log Double)] -> Double
- sampler :: SamplerIO a -> IO a
Documentation
newtype SamplerT g m a Source #
The sampling interpretation of a probabilistic program Here m is typically IO or ST
SamplerT | |
|
Instances
type SamplerIO = SamplerT (IOGenM StdGen) IO Source #
convenient type synonym to show specializations of SamplerT to particular pairs of monad and RNG
type SamplerST s = SamplerT (STGenM StdGen s) (ST s) Source #
convenient type synonym to show specializations of SamplerT to particular pairs of monad and RNG
sampleIOfixed :: SamplerIO a -> IO a Source #
Run the sampler with a fixed random seed
sampleWith :: SamplerT 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