HORIZON HASKELLDocslts/ghc-10.0.x77a86622026-10-31Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 77a8662 · 2026-10-31

Modulemwc-random-0.15.3.0Haskell2010

System.Random.MWC.Distributions

Pseudo-random number generation for non-uniform distributions.

Contents
  1. Variates: non-uniformly distributed values
  2. Continuous distributions
  3. Discrete distribution
  4. Multivariate
  5. Permutations
  6. References
Synopsis
  • Packagemwc-random-0.15.3.0
  • Exports18
  • LanguageHaskell2010
  • LicenceBSD-2-Clause
  • SourceDistributions.hs

Variates: non-uniformly distributed values

Continuous distributions

valuestandard :: StatefulGen g m => g -> m Double

Generate a normally distributed random variate with zero mean and unit variance.

The implementation uses Doornik's modified ziggurat algorithm. Compared to the ziggurat algorithm usually used, this is slower, but generates more independent variates that pass stringent tests of randomness.

Discrete distribution

valuegeometric0
  1. :: StatefulGen g m
  2. => Double

    p success probability lies in (0,1]

  3. -> g

    Generator

  4. -> m Int

Random variate generator for the geometric distribution, computing the number of failures before success. Distribution's support is [0..].

valuegeometric1
  1. :: StatefulGen g m
  2. => Double

    p success probability lies in (0,1]

  3. -> g

    Generator

  4. -> m Int

Random variate generator for geometric distribution for number of trials. Distribution's support is [1..] (i.e. just geometric0 shifted by 1).

valuebinomial
  1. :: StatefulGen g m
  2. => Int

    Number of trials, must be positive.

  3. -> Double

    Probability of success p \in [0,1]

  4. -> g

    Generator

  5. -> m Int

Random variate generator for Binomial distribution. Will throw exception when parameters are out range.

The probability of getting exactly k successes in n trials is given by the probability mass function:

f(k;n,p) = \Pr(X = k) = \binom n k p^k(1-p)^{n-k}

valuepoisson
  1. :: StatefulGen g m
  2. => Double

    Rate parameter, also known as \lambda

  3. -> g

    Generator

  4. -> m Int

Random variate generate for Poisson distribution.

If parameter λ is within 10 σ or greater than maxBound :: Int error is raised since result may not be representable as Int

Multivariate

Permutations

valueuniformShuffle
  1. :: (StatefulGen g m, PrimMonad m, Vector v a)
  2. => v a
  3. -> g
  4. -> m (v a)

Random variate generator for a uniformly distributed shuffle (all shuffles are equiprobable) of a vector. It uses Fisher-Yates shuffle algorithm.

References