Random samplers for some common distributions, based on splitmix.
|LTS Haskell 19.25:||0.9.0.0|
|Stackage Nightly 2022-09-25:||1.0.0|
|Latest on Hackage:||1.0.0|
Module documentation for 1.0.0
Random samplers for some common distributions, as well as a convenient interface for composing them, based on
Compose your random sampler out of simpler ones thanks to the Applicative and Monad interface, e.g. this is how you would declare and sample a binary mixture of Gaussian random variables:
import Control.Monad (replicateM) import System.Random.SplitMix.Distributions (Gen, sample, bernoulli, normal) process :: Gen Double process = do coin <- bernoulli 0.7 if coin then normal 0 2 else normal 3 1 dataset :: [Double] dataset = sample 1234 $ replicateM 20 process
and sample your data in a pure (
sample) or monadic (
The library is built on top of
splitmix, so the caveats on safety and performance that apply there are relevant here as well.
- add MonadReader r (GenT m) instance
- fixed MonadState (GenT m) instance via MonadTrans (i.e. as done in ‘mtl’)
- ensure it builds with ghc 8.6.5 (== stackage lts 14.27) as well
- relax lower bound
- add MonadThrow (GenT m) instance
- add sampleIO, samplesIO
- clarify pure vs IO-based sampling in the docs
- add Chinese Restaurant Process
- add Log-normal, Laplace, Weibull distributions
- add Discrete, Categorical, Zipf-Mandelbrot distributions
- type signatures of all generators are now parametrized over some Monad m rather than Identity. This allows for more flexibility on the use site.
- add Pareto, Dirichlet, multinomial distributions