mwc-random-monad-0.7.2.0: Monadic interface for mwc-random

Copyright(c) 2010-2012 Aleksey Khudyakov
LicenseBSD3
Maintaineralexey.skladnoy@gmail.com
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell98

System.Random.MWC.Distributions.Monad

Contents

Description

Monadic wrapper for various distributions generators.

Synopsis

Variates: non-uniformly distributed values

Continuous distributions

normal Source

Arguments

:: MonadPrim m 
=> Double

Mean

-> Double

Standard deviation

-> Rand m Double 

Normally distributed variable

standard :: MonadPrim m => Rand m Double Source

Normally distributed variables with mean 0 and 1 standard deviation

exponential Source

Arguments

:: MonadPrim m 
=> Double

Scale parameter

-> Rand m Double 

Generate exponentially distributed random variate.

truncatedExp Source

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.

gamma Source

Arguments

:: MonadPrim m 
=> Double

Shape parameter

-> Double

Scale parameter

-> Rand m Double 

Random variate generator for gamma distribution.

chiSquare Source

Arguments

:: MonadPrim m 
=> Int

Number of degrees of freedom

-> Rand m Double 

Random variate generator for chi square distribution.

beta Source

Arguments

:: MonadPrim m 
=> Double

alpha (>0)

-> Double

beta (>0)

-> Rand m Double 

Random variate generator for Beta distribution

Discrete distribution

categorical Source

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.

geometric0 Source

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..].

geometric1 Source

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).

bernoulli Source

Arguments

:: MonadPrim m 
=> Double

Probability of success (returning True)

-> Rand m Bool 

Random variate generator for Bernoulli distribution

Multivariate

dirichlet Source

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.