The generators in this section are provided for compatibility with existing libraries. If you are converting an existing program to use GSL then you can select these generators to check your new implementation against the original one, using the same random number generator. After verifying that your new program reproduces the original results you can then switch to a higher-quality generator.
Note that most of the generators in this section are based on single linear congruence relations, which are the least sophisticated type of generator. In particular, linear congruences have poor properties when used with a non-prime modulus, as several of these routines do (e.g. with a power of two modulus, @math{2^31} or @math{2^32}). This leads to periodicity in the least significant bits of each number, with only the higher bits having any randomness. Thus if you want to produce a random bitstream it is best to avoid using the least significant bits.
RANF
. Its sequence is
defined on 48-bit unsigned integers with @math{a = 44485709377909} and @math{m = 2^48}. The seed specifies the lower 32 bits of the initial value, @math{x_1}, with the lowest bit set to prevent the seed taking an even value. The upper 16 bits of @math{x_1} are set to 0. A consequence of this procedure is that the pairs of seeds 2 and 3, 4 and 5, etc produce the same sequences.
The generator compatibile with the CRAY MATHLIB routine RANF. It produces double precision floating point numbers which should be identical to those from the original RANF.
There is a subtlety in the implementation of the seeding. The initial state is reversed through one step, by multiplying by the modular inverse of @math{a} mod @math{m}. This is done for compatibility with the original CRAY implementation.
Note that you can only seed the generator with integers up to @math{2^32}, while the original CRAY implementation uses non-portable wide integers which can cover all @math{2^48} states of the generator.
The function gsl_rng_get
returns the upper 32 bits from each term
of the sequence. The function gsl_rng_uniform
uses the full 48
bits to return the double precision number @math{x_n/m}.
The period of this generator is @c{$2^{46}$} @math{2^46}.
where @math{^^} denote "exclusive-or", defined on 32-bit words. The period of this generator is about @c{$2^{250}$} @math{2^250} and it uses 250 words of state per generator.
For more information see,
For more information see,
MTH$RANDOM
. Its sequence is,
with @math{a = 69069}, @math{c = 1} and @math{m = 2^32}. The seed specifies the initial value, @math{x_1}. The period of this generator is @math{2^32} and it uses 1 word of storage per generator.
with @math{a = 1664525} and @math{m = 2^32}. The seed specifies the initial value, @math{x_1}.
RANDU
generator. Its sequence is
with @math{a = 65539} and @math{m = 2^31}. The seed specifies the initial value, @math{x_1}. The period of this generator was only @math{2^29}. It has become a textbook example of a poor generator.
with @math{a = 16807} and @math{m = 2^31 - 1 = 2147483647}. The seed specifies the initial value, @math{x_1}. The period of this generator is about @math{2^31}.
This generator is used in the IMSL Library (subroutine RNUN) and in MATLAB (the RAND function). It is also sometimes known by the acronym "GGL" (I'm not sure what that stands for).
For more information see,
gsl_rng_uni32
. The original source code is available from NETLIB.
The original source code is available from NETLIB. For more information see,