gfm

Translation of SimpleRNG. Removed the builtin RNG to use std.random, but kept the distribution functions. John D. Cook confirmed this code as public domain.

Authors
John D. Cook.
See Also
www.johndcook.com/cpp_random_number_generation.html

double  randNormal(RNG)(ref RNG rng, double mean = 0.000000, double standardDeviation = 1.00000);

Returns
Normal (Gaussian) random sample.
See Also
Box-Muller algorithm.

double  randExponential(RNG)(ref RNG rng, double mean = 1.00000);

Returns
Exponential random sample with specified mean.

double  randGamma(RNG)(ref RNG rng, double shape, double scale);

Returns
Gamma random sample.
See Also
"A Simple Method for Generating Gamma Variables"

by George Marsaglia and Wai Wan Tsang. ACM Transactions on Mathematical Software

Vol 26, No 3, September 2000, pages 363-372.

double  randChiSquare(RNG)(ref RNG rng, double degreesOfFreedom);

Returns
Chi-square sample.

double  randInverseGamma(RNG)(ref RNG rng, double shape, double scale);

Returns
Inverse-gamma sample.

double  randWeibull(RNG)(ref RNG rng, double shape, double scale);

Returns
Weibull sample.

double  randCauchy(RNG)(ref RNG rng, double median, double scale);

Returns
Cauchy sample.

double  randStudentT(RNG)(ref RNG rng, double degreesOfFreedom);

Returns
Student-t sample.
See Also
Seminumerical Algorithms by Knuth.

double  randLaplace(RNG)(ref RNG rng, double mean, double scale);

Returns
Laplace distribution random sample (also known as the double exponential distribution).

double  randLogNormal(RNG)(ref RNG rng, double mu, double sigma);

Returns
Log-normal sample.

double  randBeta(RNG)(ref RNG rng, double a, double b);

Returns
Beta sample.

int  randPoisson(RNG)(ref RNG rng, double lambda);

Returns
Poisson sample.