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

[ bsd3, library, math ] [ Propose Tags ] [ Report a vulnerability ]

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]

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 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, 0.9.0.0, 1.0.0
Change log ChangeLog.md
Dependencies base (>=4.7 && <5), containers, erf, exceptions, mtl, splitmix, transformers [details]
Tested with ghc ==8.6.5, ghc ==8.10.4
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 2022-05-05T05:47:31Z
Distributions LTSHaskell:1.0.0, NixOS:1.0.0, Stackage:1.0.0
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 1427 total (29 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2022-05-05 [all 1 reports]

Readme for splitmix-distributions-1.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.