LinearCongruentialEngine generators with well-chosen parameters. MinstdRand0 implements Park and Miller's "minimal standard" generator, which uses 16807 for the multiplier. MinstdRand implements a variant that has slightly better spectral behaviour by using the multiplier 48271. Both generators are rather simplistic.
Mersenne Twister generators with well-chosen parameters. Mt11213b offers a generator with a period of 2^11213 - 1 and a 32-bit datatype, while Mt19937 and Mt19937_64 offer generators with 32- and 64-bit datatypes respectively, both having a period of 2^19937 - 1. The three generators offer a good uniform distribution in up to 350, 623 and 311 dimensions respectively. Mt19937 is the most typical configuration, widely used in many different programming languages as a high-quality default random number generator.
The "default", "recommended" RNG type for the current platform, implemented as an alias to one of the generators defined elsewhere in this module. Its use is suggested if you want to generate good-quality random numbers without caring about the minutiae of the method being used. The default thread-local RNG instance rndGen is of type Random.
TypeTuple of all uniform RNGs defined in this module.
Define XorshiftEngine generators with well-chosen parameters as provided by Marsaglia (2003). The default provided by Xorshift corresponds to the 128-bit generator as an optimal balance of statistical quality and speed.
Linear congruential generators are some of the oldest algorithms for generating pseudo-random numbers. They tend to be fast but not of particularly high statistical quality, so their use is recommended only in very constrained circumstances, e.g. where memory is very severely restricted. Even then, consider using an Xorshift generator instead, as this should provide much higher statistical quality.
The Mersenne Twister generator, developed by Makoto Matsumoto and Takuji Nishimura (1997), allows for fast generation of high-quality pseudorandom numbers, and is widely used as a default random number generator by many programming languages, including D. The current implementation is adapted from that of Boost.Random and supports both 32- and 64-bit datatypes.
The Xorshift family of generators, developed by George Marsaglia (2003), offer high-quality random number generation with minimal storage requirements and computational cost. They are therefore highly suitable for use in low-memory environments or slower processors. The current implementation supports Xorshift random number generation with a 32-bit datatype only.
Global random number generator used by various functions in this package whenever no other generator is specified. It is allocated per-thread and initialized with a different unpredictable seed for each thread.
A "good" seed for initializing random number generators. Initializing with unpredictableSeed ensures that RNGs produce different pseudo-random sequences each time they are run.
The Mersenne Twister implementation is adapted from the C++ implementation in Boost.Random by Jens Maurer and Steven Watanabe, similarly licensed under the Boost Software License 1.0.
See Source File
$(HAPSRC hap/random/_generator.d)
© 2008-2011 Andrei Alexandrescu, 2011 Masahiro Nakagawa, 2013-2014 Joseph Rushton Wakeling
Implements algorithms for uniform pseudo-random number generation. Following the definition used in the C++11 Standard Template Library $(LESS)_random$(GREATER) header, a uniform random number generator is defined to be an Input Range whose values are unsigned integer values drawn from the closed interval [min, max], such that each value among the possible set of results has (ideally) equal probability of being next in the sequence. Pseudo-random number generators are typically implemented as Forward Ranges, but this is not a requirement.
The uniform random number generators provided by this module are implemented as final classes to ensure reference type semantics. These semantics are assumed by all other functions in the package, so user-defined value-type RNGs may fail in unexpected ways.
Non-deterministic random number generators, or random devices, are provided in a separate module (currently experimental).