mwc-random-0.15.0.2: Fast, high quality pseudo random number generation
Copyright (c) 2012 Bryan O'Sullivan
License BSD3
Maintainer bos@serpentine.com
Stability experimental
Portability portable
Safe Haskell None
Language Haskell2010

System.Random.MWC.Distributions

Description

Pseudo-random number generation for non-uniform distributions.

Synopsis

Variates: non-uniformly distributed values

Continuous distributions

normal Source #

Arguments

:: StatefulGen g m
=> Double

Mean

-> Double

Standard deviation

-> g
-> m Double

Generate a normally distributed random variate with given mean and standard deviation.

standard :: StatefulGen g m => g -> m Double Source #

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.

exponential Source #

Arguments

:: StatefulGen g m
=> Double

Scale parameter

-> g

Generator

-> m Double

Generate an exponentially distributed random variate.

truncatedExp Source #

Arguments

:: StatefulGen g m
=> Double

Scale parameter

-> ( Double , Double )

Range to which distribution is truncated. Values may be negative.

-> g

Generator.

-> m Double

Generate truncated exponentially distributed random variate.

gamma Source #

Arguments

:: StatefulGen g m
=> Double

Shape parameter

-> Double

Scale parameter

-> g

Generator

-> m Double

Random variate generator for gamma distribution.

chiSquare Source #

Arguments

:: StatefulGen g m
=> Int

Number of degrees of freedom

-> g

Generator

-> m Double

Random variate generator for the chi square distribution.

beta Source #

Arguments

:: StatefulGen g m
=> Double

alpha (>0)

-> Double

beta (>0)

-> g

Generator

-> m Double

Random variate generator for Beta distribution

Discrete distribution

categorical Source #

Arguments

:: ( StatefulGen g m, Vector v Double )
=> v Double

List of weights [>0]

-> g

Generator

-> m Int

Random variate generator for categorical distribution.

Note that if you need to generate a lot of variates functions System.Random.MWC.CondensedTable will offer better performance. If only few is needed this function will faster since it avoids costs of setting up table.

logCategorical Source #

Arguments

:: ( StatefulGen g m, Vector v Double )
=> v Double

List of logarithms of weights

-> g

Generator

-> m Int

Random variate generator for categorical distribution where the weights are in the log domain. It's implemented in terms of categorical .

geometric0 Source #

Arguments

:: StatefulGen g m
=> Double

p success probability lies in (0,1]

-> g

Generator

-> m Int

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

geometric1 Source #

Arguments

:: StatefulGen g m
=> Double

p success probability lies in (0,1]

-> g

Generator

-> m Int

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

bernoulli Source #

Arguments

:: StatefulGen g m
=> Double

Probability of success (returning True)

-> g

Generator

-> m Bool

Random variate generator for Bernoulli distribution

Multivariate

dirichlet Source #

Arguments

:: ( StatefulGen g m, Traversable t)
=> t Double

container of parameters

-> g

Generator

-> m (t Double )

Random variate generator for Dirichlet distribution

Permutations

uniformPermutation :: forall g m v. ( StatefulGen g m, PrimMonad m, Vector v Int ) => Int -> g -> m (v Int ) Source #

Random variate generator for uniformly distributed permutations. It returns random permutation of vector [0 .. n-1] .

This is the Fisher-Yates shuffle

uniformShuffle :: ( StatefulGen g m, PrimMonad m, Vector v a) => v a -> g -> m (v a) Source #

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

uniformShuffleM :: ( StatefulGen g m, PrimMonad m, MVector v a) => v ( PrimState m) a -> g -> m () Source #

In-place uniformly distributed shuffle (all shuffles are equiprobable)of a vector.

References