| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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, 2^31 or 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
x_{n+1} = (a x_n) mod m
|
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 a mod m. This is done for compatibility with the original CRAY implementation.
Note that you can only seed the generator with integers up to 2^32, while the original CRAY implementation uses non-portable wide integers which can cover all 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 x_n/m.
The period of this generator is 2^46.
x_n = x_{n-103} ^^ x_{n-250}
|
For more information see,
For more information see,
MTH$RANDOM. Its sequence is,
x_{n+1} = (a x_n + c) mod m
|
x_{n+1} = (a x_n) mod m
|
RANDU generator. Its sequence is
x_{n+1} = (a x_n) mod m
|
x_{n+1} = (a x_n) mod m
|
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.
t = u_{n-273} + u_{n-607}
u_n = t - floor(t)
|
The original source code is available from NETLIB. For more information see,
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |