Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/ocramz/splitmix-distributions
- Owner: ocramz
- License: bsd-3-clause
- Created: 2021-05-03T08:21:11.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-05-05T05:47:22.000Z (over 2 years ago)
- Last Synced: 2024-05-01T23:26:09.609Z (6 months ago)
- Topics: random-generation, random-sampling, splitmix, statistics
- Language: Haskell
- Homepage:
- Size: 22.5 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: ChangeLog.md
- License: LICENSE
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 1dataset :: [Double]
dataset = sample 1234 $ replicateM 20 processand 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.