Fast, high quality pseudo random number generation

Version on this page:
LTS Haskell 22.30:
Stackage Nightly 2024-07-22:
Latest on Hackage:

See all snapshots mwc-random appears in

BSD-3-Clause licensed and maintained by Bryan O'Sullivan
This version can be pinned in stack with:mwc-random-,1810

Efficient, general purpose pseudo-random number generation

Build Status Build status

This package provides the System.Random.MWC module, a Haskell library for generating high-quality pseudo-random numbers in a space- and time-efficient way.

Get involved!

Please report bugs via the github issue tracker.

Master git git repository:

  • git clone git://

There’s also a Mercurial mirror:

  • hg clone

(You can create and contribute changes using either Mercurial or git.)


This library is written and maintained by Bryan O’Sullivan, [email protected].


Changes in

  • Low level functions for acquiring random data for initialization of PRGN state is moved to System.Random.MWC.SeedSource module

  • Ensure that carry is always correct when restoring PRNG state from seed. Only affects users who create 258 element seed manually. (#63, #65)

Changes in

  • tablePoisson now can handle λ>1923, see #59 for details. That required intoduction of dependency on math-functions.

Changes in

  • logCategorical added

Changes in

  • withSystemRandom uses RtlGenRandom for seeding generator on windows

Changes in

  • primitive-0.6 compatibility

Changes in

  • Monadic variant of vector shuffle added: uniformShuffleM

  • Context on uniformShuffle loosened

Changes in

  • Fixed crash during gen. initialization on Windows when stderr is not available (#36).

Changes in

  • Generators for beta, Bernoully, Dirichlet and categorical distributions added.

  • Functions for generating random shuffles added.

Changes in

  • GHC 7.9 support

Changes in

  • Long standing performance problem in normal distribution fixed (#16)

Changes in

  • createSystemRandom added

Changes in

  • Workaround for GHC bug 8072 (bug 25). GHC 7.6 on 32-bit platrofms is affected.

  • Generators for truncated exponential and geometric distributions added.

Changes in

  • Fucntion asGenIO and asGenST added.

  • Generation of discrete random variates using condensed tables methed. Tables for Poisson and binomial distributions are provided.