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

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain] [Publish]

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]

Properties

Versions 0.1.0.0, 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), 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-03T09:33:37Z

Modules

[Index]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees


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