A .Net library containing alternate implementations of the System.Random
type.
Each random generator is derived from the System.Random
class of the .Net standard library, and may be used in the exact same way. While they are implemented in a number of different ways, each one allows the programmer to use a collection of unsigned seeds, rather than a single 32-bit seed, and (hopefully) fulfills the following principles:
- An arbitrary number of seeds may be passed to the constructor.
- All seeds are equal; there are no cases where some seeds are "better" or "get better random results" than others.
- As an extension of point 2, multiple successive 0-values in the seed collection should not necessarily result in the random number generator outputting multiple successive 0-values.
The base class is URandomGen.RandomGen
; all other classes in this library are derived from this class.
RandomCMWC
is based on the complementary multiply-with-carry random number generator invented by George Marsaglia, described here; the implementation is derived from a post which Marsaglia made to the comp.lang.c newsgroup in 2003.
RandomXorshift
is based on the xorshift random number generator, also invented by George Marsaglia, described here. The implementation is derived from the aforementioned comp.lang.c post, but with 32 seeds stored instead of 5.
RandomMersenne
is based on the Mersenne Twister, developed by Makoto Matsumoto and Takuji Nishimura. The name comes from the fact that its period length is chosen to be a Mersenne prime. The class is mostly a port of Matsumodo and Nishimura's MT19937 implementation, which is based on the Mersenne prime 219937-1.
RandomWichHill
is a variation on the Wichmann-Hill algorithm, and stores 64 values instead of 3.
RandomCrypt
simply uses a System.Security.Cryptography.RandomNumberGenerator
to generate its random values.
The URandomGen library is released under the three-clause BSD license. All of the classes herein are derived from existing principles; see LICENSE-ThirdParty.md for more information.