Random number generation based on modeling random variables in two complementary ways: first, by the parameters of standard mathematical distributions and, second, by an abstract type (RVar) which can be composed and manipulated monadically and sampled in either monadic or "pure" styles.

The primary purpose of this library is to support defining and sampling a wide variety of high quality random variables. Quality is prioritized over speed, but performance is an important goal too.

In my testing, I have found it capable of speed comparable to other Haskell libraries, but still a fair bit slower than straight C implementations of the same algorithms.


  • Chnages in

    • Drop usage of random-source in favor of random
  • Changes in Update to random-1.2. Revert changes (which added an extra constraint to Data.Random.Sample.sampleState and Data.Random.Sample.sampleStateT).

  • Changes in Compatibility with ghc 8.8.

  • Changes in Remove dependence on log-domain. Raise lower bound for base to 4.9.

  • Changes in Add PDF instance for Poisson.

  • Changes in Add Simplex, fix logBetaPdf, fix binomialPdf and binomialCdf to actually use the numerically stable method!

  • Changes in 2.6.1: now supports probability density functions and log probability density functions via the PDF class, similar to R and initially just for the Beta, Binomial, Normal and Uniform distributions. The log Binomial probability density function uses Fast and Accurate Computation of Binomial Probabilities by Catherine Loader (this is what is implemented in R and Octave) to minimize the occurrence of underflow.

  • Changes in Added a Lift instance that resolves a common overlapping-instance issue in user code.

  • Changes in Should now build on GHC 7.6

  • Changes in Added stretched exponential distribution, contributed by Ben Gamari.

  • Changes in Bug fixes in Data.Random.Distribution.Categorical.

  • Changes in Changed some one-field data types to newtypes, updated types for GHC 7.4’s removal of Eq and Show from the context of Num, and added RVarT versions of random variables in Data.Random.List