tango.math.random.Ziggurat

License:

BSD style: see license.txt

Version:

Initial release: July 2008

Author:

Fawzi Mohamed
struct Ziggurat(RandG, T, alias probDensityF, alias tailGenerator, bool hasNegative = true)
ziggurat method for decreasing distributions. Marsaglia, Tsang, Journal of Statistical Software, 2000 If has negative is true the distribution is assumed to be symmetric with respect to 0, otherwise it is assumed to be from 0 to infinity. Struct based to avoid extra indirection when wrapped in a class (and it should be wrapped in a class and not used directly). Call style initialization avoided on purpose (this is a big structure, you don't want to return it)
Ziggurat create(alias invProbDensityF, alias cumProbDensityFCompl)(RandG rGenerator, real xLast = -1.0L, bool check_error = true) [static]
initializes the ziggurat
T getFastRandom()
returns a single value with the probability distribution of the current Ziggurat and slightly worse randomness (in the normal case uses only 32 random bits). Cannot be 0.
T getRandom()
returns a single value with the probability distribution of the current Ziggurat
U randomize(U)(ref U a)
initializes the argument with the probability distribution given and returns it for arrays this might potentially be faster than a naive loop
template randomizeOp2(alias op)
initializes the variable with the result of mapping op on the random numbers (of type T)
U randomizeOp(U, S)(scope S delegate(T) op, ref U a)
initializes the variable with the result of mapping op on the random numbers (of type T)