| Copyright | (c) Adam Scibior 2015-2020 |
|---|---|
| License | MIT |
| Maintainer | leonhard.markert@tweag.io |
| Stability | experimental |
| Portability | GHC |
| Safe Haskell | None |
| Language | Haskell2010 |
Control.Monad.Bayes.Sampler
Description
SamplerIO and SamplerST are instances of MonadSample. Apply a MonadCond
transformer to obtain a MonadInfer that can execute probabilistic models.
Synopsis
- data SamplerIO a
- sampleIO :: SamplerIO a -> IO a
- sampleIOfixed :: SamplerIO a -> IO a
- sampleIOwith :: SamplerIO a -> GenIO -> IO a
- data Seed
- newtype SamplerST a = SamplerST (forall s. ReaderT (GenST s) (ST s) a)
- runSamplerST :: SamplerST a -> ReaderT (GenST s) (ST s) a
- sampleST :: SamplerST a -> State Seed a
- sampleSTfixed :: SamplerST a -> a
Documentation
An IO based random sampler using the MWC-Random package.
Instances
| Monad SamplerIO Source # | |
| Functor SamplerIO Source # | |
| Applicative SamplerIO Source # | |
Defined in Control.Monad.Bayes.Sampler | |
| MonadIO SamplerIO Source # | |
Defined in Control.Monad.Bayes.Sampler | |
| MonadSample SamplerIO Source # | |
Defined in Control.Monad.Bayes.Sampler Methods random :: SamplerIO Double Source # uniform :: Double -> Double -> SamplerIO Double Source # normal :: Double -> Double -> SamplerIO Double Source # gamma :: Double -> Double -> SamplerIO Double Source # beta :: Double -> Double -> SamplerIO Double Source # bernoulli :: Double -> SamplerIO Bool Source # categorical :: Vector v Double => v Double -> SamplerIO Int Source # logCategorical :: (Vector v (Log Double), Vector v Double) => v (Log Double) -> SamplerIO Int Source # uniformD :: [a] -> SamplerIO a Source # geometric :: Double -> SamplerIO Int Source # poisson :: Double -> SamplerIO Int Source # dirichlet :: Vector v Double => v Double -> SamplerIO (v Double) Source # | |
sampleIO :: SamplerIO a -> IO a Source #
Initialize a pseudo-random number generator using randomness supplied by the operating system. For efficiency this operation should be applied at the very end, ideally once per program.
sampleIOfixed :: SamplerIO a -> IO a Source #
Like sampleIO, but with a fixed random seed.
Useful for reproducibility.
sampleIOwith :: SamplerIO a -> GenIO -> IO a Source #
Like sampleIO but with a custom pseudo-random number generator.
An immutable snapshot of the state of a Gen.
An ST based random sampler using the mwc-random package.
Instances
| Monad SamplerST Source # | |
| Functor SamplerST Source # | |
| Applicative SamplerST Source # | |
Defined in Control.Monad.Bayes.Sampler | |
| MonadSample SamplerST Source # | |
Defined in Control.Monad.Bayes.Sampler Methods random :: SamplerST Double Source # uniform :: Double -> Double -> SamplerST Double Source # normal :: Double -> Double -> SamplerST Double Source # gamma :: Double -> Double -> SamplerST Double Source # beta :: Double -> Double -> SamplerST Double Source # bernoulli :: Double -> SamplerST Bool Source # categorical :: Vector v Double => v Double -> SamplerST Int Source # logCategorical :: (Vector v (Log Double), Vector v Double) => v (Log Double) -> SamplerST Int Source # uniformD :: [a] -> SamplerST a Source # geometric :: Double -> SamplerST Int Source # poisson :: Double -> SamplerST Int Source # dirichlet :: Vector v Double => v Double -> SamplerST (v Double) Source # | |
sampleST :: SamplerST a -> State Seed a Source #
Run the sampler with a supplied seed.
Note that 'State Seed' is much less efficient than SamplerST for composing computation.
sampleSTfixed :: SamplerST a -> a Source #
Run the sampler with a fixed random seed.