prob-fx-0.1.0.2: A library for modular probabilistic modelling
Safe HaskellNone
LanguageHaskell2010

Sampler

Description

An IO-based sampling monad.

Synopsis

Sampler monad

data Sampler a Source #

Sampler type, for running IO computations alongside a random number generator

Instances

Instances details
Monad Sampler Source # 
Instance details

Defined in Sampler

Methods

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

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

return :: a -> Sampler a #

Functor Sampler Source # 
Instance details

Defined in Sampler

Methods

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

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

Applicative Sampler Source # 
Instance details

Defined in Sampler

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 #

liftS :: IO a -> Sampler a Source #

Lift an IO computation into Sampler

sampleIO :: Sampler a -> IO a Source #

Takes a Sampler, provides it a random generator, and runs the sampler in the IO context

sampleIOFixed :: Sampler a -> IO a Source #

Takes a Sampler, provides it a fixed generator, and runs the sampler in the IO context

createSampler :: (GenIO -> IO a) -> Sampler a Source #

Takes a distribution which awaits a generator, and returns a Sampler

Sampling functions

Given their distribution parameters, these functions await a generator and then sample a value from the distribution in the IO monad.

sampleCauchy Source #

Arguments

:: Double

location

-> Double

scale

-> GenIO -> IO Double 

sampleNormal Source #

Arguments

:: Double

mean

-> Double

standard deviation

-> GenIO -> IO Double 

sampleUniform Source #

Arguments

:: Double

lower-bound

-> Double

upper-bound

-> GenIO -> IO Double 

sampleDiscreteUniform Source #

Arguments

:: Int

lower-bound

-> Int

upper-bound

-> GenIO -> IO Int 

sampleGamma Source #

Arguments

:: Double

shape k

-> Double

scale θ

-> GenIO -> IO Double 

sampleBeta Source #

Arguments

:: Double

shape α

-> Double

shape β

-> GenIO -> IO Double 

sampleBernoulli Source #

Arguments

:: Double

probability of True

-> GenIO -> IO Bool 

sampleBinomial Source #

Arguments

:: Int

number of trials

-> Double

probability of successful trial

-> GenIO -> IO [Bool] 

sampleCategorical Source #

Arguments

:: Vector Double

probabilities

-> GenIO -> IO Int 

sampleDiscrete Source #

Arguments

:: [Double]

probabilities

-> GenIO -> IO Int 

samplePoisson Source #

Arguments

:: Double

rate λ

-> GenIO -> IO Int 

sampleDirichlet Source #

Arguments

:: [Double]

concentrations

-> GenIO -> IO [Double]