Description

Monadic wrapper for various distributions generators.

Synopsis

# Variates: non-uniformly distributed values

## Continuous distributions

Arguments

 :: MonadPrim m => Double Mean -> Double Standard deviation -> Rand m Double

Normally distributed variable

Normally distributed variables with mean 0 and 1 standard deviation

Arguments

 :: MonadPrim m => Double Scale parameter -> Rand m Double

Generate exponentially distributed random variate.

Arguments

 :: MonadPrim m => Double Scale parameter -> (Double, Double) Range to which distribution is truncated. Values may be negative. -> Rand m Double

Generate truncated exponentially distributed random variate.

Arguments

 :: MonadPrim m => Double Shape parameter -> Double Scale parameter -> Rand m Double

Random variate generator for gamma distribution.

Arguments

 :: MonadPrim m => Int Number of degrees of freedom -> Rand m Double

Random variate generator for chi square distribution.

Arguments

 :: MonadPrim m => Double alpha (>0) -> Double beta (>0) -> Rand m Double

Random variate generator for Beta distribution

## Discrete distribution

Arguments

 :: (MonadPrim m, Vector v Double) => v Double List of weights [>0] -> Rand 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.

Arguments

 :: MonadPrim m => Double p success probability lies in (0,1] -> Rand m Int

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

Arguments

 :: MonadPrim m => Double p success probability lies in (0,1] -> Rand m Int

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

Arguments

 :: MonadPrim m => Double Probability of success (returning True) -> Rand m Bool

Random variate generator for Bernoulli distribution

## Multivariate

Arguments

 :: (MonadPrim m, Traversable t) => t Double container of parameters -> Rand m (t Double)

Random variate generator for Dirichlet distribution

# Permutations

uniformPermutation :: (MonadPrim m, Vector v Int) => Int -> Rand 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 :: (MonadPrim m, Vector v a) => v a -> Rand m (v a) Source

Random variate generator for a uniformly distributed shuffle of a vector.

uniformShuffleM :: (MonadPrim m, MVector v a, PrimState m ~ PrimState (BasePrimMonad m)) => v (PrimState m) a -> Rand m () Source

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