prob-fx-0.1.0.1: 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]