tango.math.Random

License:

BSD style: see license.txt

Version:

Initial release: April 2004

Author:

Various

Deprecated:

Please use Kiss instead. We'll add a fully featured Random in a future release
class Random #
KISS (via George Marsaglia)
the idea is to use simple, fast, individually promising generators to get a composite that will be fast, easy to code have a very long period and pass all the tests put to it. The three components of KISS are

x(n)=a*x(n-1)+1 mod 2^32 y(n)=y(n-1)(I+L^13)(I+R^17)(I+L^5), z(n)=2*z(n-1)+z(n-2) +carry mod 2^32 The y's are a shift register sequence on 32bit binary vectors period 2^32-1; The z's are a simple multiply-with-carry sequence with period 2^63+2^32-1.

The period of KISS is thus 2^32*(2^32-1)*(2^63+2^32-1) > 2^127

Random instance [public, static] #
Shared instance:
1
auto random = Random.instance.next;
static this() #
Create a static and shared instance:
1
auto random = Random.instance.next;
this() #
Creates and seeds a new generator with the current time
Random seed() [final] #
Seed the generator with current time
Random seed(uint seed) [final] #
Seed the generator with a provided value
uint next() [final, deprecated] #
Returns X such that 0 <= X <= uint.max
uint next(uint max) [final, deprecated] #
Returns X such that 0 <= X < max
Note that max is exclusive, making it compatible with array indexing
uint next(uint min, uint max) [final, deprecated] #
Returns X such that min <= X < max
Note that max is exclusive, making it compatible with array indexing