splitmix-distributions: Random samplers for some common distributions, based on splitmix.

[ bsd3, library, math ] [ Propose Tags ]

Random samplers for some common distributions, as well as a convenient interface for composing them, based on splitmix. Please see the README on GitHub at https://github.com/ocramz/splitmix-distributions#readme


[Skip to Readme]
Versions [faq] 0.1.0.0, 0.3.0.0, 0.4.0.0, 0.5.0.0, 0.6.0.0, 0.7.0.0, 0.8.0.0
Change log ChangeLog.md
Dependencies base (>=4.7 && <5), erf, mtl, splitmix, transformers [details]
License BSD-3-Clause
Copyright 2021 Marco Zocca
Author Marco Zocca
Maintainer ocramz
Category Math
Home page https://github.com/ocramz/splitmix-distributions#readme
Bug tracker https://github.com/ocramz/splitmix-distributions/issues
Source repo head: git clone https://github.com/ocramz/splitmix-distributions
Uploaded by ocramz at 2021-05-03T11:28:31Z
Distributions Stackage:0.8.0.0
Downloads 250 total (250 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs available [build log]
Last success reported on 2021-05-03 [all 1 reports]

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees


Readme for splitmix-distributions-0.5.0.0

[back to package description]

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.