The functions described above make no reference to the actual algorithm used. This is deliberate so that you can switch algorithms without having to change any of your application source code. The library provides a large number of generators of different types, including simulation quality generators, generators provided for compatibility with other libraries and historical generators from the past.
The following generators are recommended for use in simulation. They have extremely long periods, low correlation and pass most statistical tests.
gsl_rng_set
reproduces this.
For more information see,
The generator gsl_rng_19937
uses the corrected version of the
seeding procedure published later by the two authors above. The
original seeding procedure suffered from low-order periodicity, but can
be used by selecting the alternate generator gsl_rng_mt19937_1998
.
The generator ranlxs0
is a second-generation version of the
RANLUX algorithm of L@"uscher, which produces "luxury random
numbers". This generator provides single precision output (24 bits) at
three luxury levels ranlxs0
, ranlxs1
and ranlxs2
.
It uses double-precision floating point arithmetic internally and can be
significantly faster than the integer version of ranlux
,
particularly on 64-bit architectures. The period of the generator is
about @c{$10^{171}$}
@math{10^171}. The algorithm has mathematically proven properties and
can provide truly decorrelated numbers at a known level of randomness.
The higher luxury levels provide additional decorrelation between samples
as an additional safety margin.
These generators produce double precision output (48 bits) from the
RANLXS generator. The library provides two luxury levels
ranlxd1
and ranlxd2
.
The ranlux
generator is an implementation of the original
algorithm developed by L@"uscher. It uses a
lagged-fibonacci-with-skipping algorithm to produce "luxury random
numbers". It is a 24-bit generator, originally designed for
single-precision IEEE floating point numbers. This implementation is
based on integer arithmetic, while the second-generation versions
RANLXS and RANLXD described above provide floating-point
implementations which will be faster on many platforms.
The period of the generator is about @c{$10^{171}$}
@math{10^171}. The algorithm has mathematically proven properties and
it can provide truly decorrelated numbers at a known level of
randomness. The default level of decorrelation recommended by L@"uscher
is provided by gsl_rng_ranlux
, while gsl_rng_ranlux389
gives the highest level of randomness, with all 24 bits decorrelated.
Both types of generator use 24 words of state per generator.
For more information see,
where the two underlying generators @math{x_n} and @math{y_n} are,
with coefficients @math{a_1 = 0}, @math{a_2 = 63308}, @math{a_3 = -183326}, @math{b_1 = 86098}, @math{b_2 = 0}, @math{b_3 = -539608}, and moduli @math{m_1 = 2^31 - 1 = 2147483647} and @math{m_2 = 2145483479}.
The period of this generator is @math{2^205} (about @math{10^61}). It uses 6 words of state per generator. For more information see,
with @math{a_1 = 107374182}, @math{a_2 = a_3 = a_4 = 0}, @math{a_5 = 104480} and @math{m = 2^31 - 1}.
The period of this generator is about @math{10^46}. It uses 5 words of state per generator. More information can be found in the following paper,
where,
computed modulo
@math{2^32}. In the formulas above
@math{^^}
denotes "exclusive-or". Note that the algorithm relies on the properties
of 32-bit unsigned integers and has been implemented using a bitmask
of 0xFFFFFFFF
to make it work on 64 bit machines.
The period of this generator is @c{$2^{88}$} @math{2^88} (about @math{10^26}). It uses 3 words of state per generator. For more information see,
gfsr4
generator is like a lagged-fibonacci generator, and
produces each number as an xor
'd sum of four previous values.
Ziff (ref below) notes that "it is now widely known" that two-tap registers (such as R250, which is described below) have serious flaws, the most obvious one being the three-point correlation that comes from the definition of the generator. Nice mathematical properties can be derived for GFSR's, and numerics bears out the claim that 4-tap GFSR's with appropriately chosen offsets are as random as can be measured, using the author's test.
This implementation uses the values suggested the the example on p392 of Ziff's article: @math{A=471}, @math{B=1586}, @math{C=6988}, @math{D=9689}.
If the offsets are appropriately chosen (such the one ones in this implementation), then the sequence is said to be maximal. I'm not sure what that means, but I would guess that means all states are part of the same cycle, which would mean that the period for this generator is astronomical; it is @math{(2^K)^D \approx 10^{93334}} where @math{K=32} is the number of bits in the word, and D is the longest lag. This would also mean that any one random number could easily be zero; ie @math{0 <= r < 2^32}.
Ziff doesn't say so, but it seems to me that the bits are completely independent here, so one could use this as an efficient bit generator; each number supplying 32 random bits. The quality of the generated bits depends on the underlying seeding procedure, which may need to be improved in some circumstances.
For more information see,