- Mersene Twister random number generator

Statistical functions
(AFL 3.0)

SYNTAX mtRandom( seed = Null )
mtRandomA( seed = Null )
FUNCTION mtRandom( seed = Null ) - returns single random number (scalar) in the range [0,1)
mtRandomA( seed = Null ) - returns array of random numbers in the range of [0,1)

seed is random generator seed value. If you don't specify one, the random number generator is automatically initialized with current time as a seed that guarantees unique sequence

Both functions use Mersene Twister mt19973ar-cok algorithm. (Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura.)

Mersene Twister is vastly superior to C-runtime pseudo-random generator available via Random() function.

It has a period of 2^19973 = approx 2.9*10^6012 For more information visit:

See also: M. Matsumoto and T. Nishimura, "Mersenne Twister: A 623-Dimensionally Equidistributed Uniform Pseudo-Random Number Generator", ACM Transactions on Modeling and Computer Simulation, Vol. 8, No. 1, January 1998, pp 3--30.

EXAMPLE printf("Random number: %g", mtRandom() );
SEE ALSO RANDOM() function


The mtRandom function is used in the following formulas in AFL on-line library:

More information:

Updated on-line reference