Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ocramz/splitmix-distributions

Sampling procedures for some common random variables based on splitmix
https://github.com/ocramz/splitmix-distributions

random-generation random-sampling splitmix statistics

Last synced: 22 days ago
JSON representation

Sampling procedures for some common random variables based on splitmix

Awesome Lists containing this project

README

        

# splitmix-distributions

Random samplers for some common distributions, as well as a convenient interface for composing them, based on `splitmix`.

## Usage

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 (`sampleT`) setting.

## Implementation details

The library is built on top of `splitmix`, so the caveats on safety and performance that apply there are relevant here as well.