[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |

## 17.11 Other random number generators

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.

__Generator:__**gsl_rng_ranf**-
This is the CRAY random number generator

`RANF`

. Its sequence is defined on 48-bit unsigned integers with*a = 44485709377909*and*m = 2^48*. The seed specifies the lower 32 bits of the initial value,*x_1*, with the lowest bit set to prevent the seed taking an even value. The upper 16 bits of*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 compatible 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*.

__Generator:__**gsl_rng_ranmar**-
This is the RANMAR lagged-fibonacci generator of Marsaglia, Zaman and Tsang. It is a 24-bit generator, originally designed for single-precision IEEE floating point numbers. It was included in the CERNLIB high-energy physics library.

__Generator:__**gsl_rng_r250**-
This is the shift-register generator of Kirkpatrick and Stoll. The sequence is based on the recurrence where

*^^*denotes “exclusive-or”, defined on 32-bit words. The period of this generator is about*2^250*and it uses 250 words of state per generator.For more information see,

- S. Kirkpatrick and E. Stoll, “A very fast shift-register sequence random number generator”, Journal of Computational Physics, 40, 517–526 (1981)

__Generator:__**gsl_rng_tt800**-
This is an earlier version of the twisted generalized feedback shift-register generator, and has been superseded by the development of MT19937. However, it is still an acceptable generator in its own right. It has a period of

*2^800*and uses 33 words of storage per generator.For more information see,

- Makoto Matsumoto and Yoshiharu Kurita, “Twisted GFSR Generators II”, ACM Transactions on Modelling and Computer Simulation, Vol. 4, No. 3, 1994, pages 254–266.

__Generator:__**gsl_rng_vax**-
This is the VAX generator

`MTH$RANDOM`

. Its sequence is, with*a = 69069*,*c = 1*and*m = 2^32*. The seed specifies the initial value,*x_1*. The period of this generator is*2^32*and it uses 1 word of storage per generator.

__Generator:__**gsl_rng_transputer**This is the random number generator from the INMOS Transputer Development system. Its sequence is, with

*a = 1664525*and*m = 2^32*. The seed specifies the initial value,*x_1*.

__Generator:__**gsl_rng_randu**-
This is the IBM

`RANDU`

generator. Its sequence is with*a = 65539*and*m = 2^31*. The seed specifies the initial value,*x_1*. The period of this generator was only*2^29*. It has become a textbook example of a poor generator.

__Generator:__**gsl_rng_minstd**-
This is Park and Miller's “minimal standard” MINSTD generator, a simple linear congruence which takes care to avoid the major pitfalls of such algorithms. Its sequence is, with

*a = 16807*and*m = 2^31 - 1 = 2147483647*. The seed specifies the initial value,*x_1*. The period of this generator is about*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,

- Park and Miller, “Random Number Generators: Good ones are hard to find”, Communications of the ACM, October 1988, Volume 31, No 10, pages 1192–1201.

__Generator:__**gsl_rng_uni**__Generator:__**gsl_rng_uni32**This is a reimplementation of the 16-bit SLATEC random number generator RUNIF. A generalization of the generator to 32 bits is provided by

`gsl_rng_uni32`

. The original source code is available from NETLIB.

__Generator:__**gsl_rng_slatec**This is the SLATEC random number generator RAND. It is ancient. The original source code is available from NETLIB.

__Generator:__**gsl_rng_zuf**This is the ZUFALL lagged Fibonacci series generator of Peterson. Its sequence is,

The original source code is available from NETLIB. For more information see,

- W. Petersen, “Lagged Fibonacci Random Number Generators for the NEC SX-3”, International Journal of High Speed Computing (1994).

__Generator:__**gsl_rng_knuthran2**This is a second-order multiple recursive generator described by Knuth in Seminumerical Algorithms, 3rd Ed., page 108. Its sequence is, with

*a_1 = 271828183*,*a_2 = 314159269*, and*m = 2^31 - 1*.

__Generator:__**gsl_rng_knuthran2002**__Generator:__**gsl_rng_knuthran**This is a second-order multiple recursive generator described by Knuth in Seminumerical Algorithms, 3rd Ed., Section 3.6. Knuth provides its C code. The updated routine

`gsl_rng_knuthran2002`

is from the revised 9th printing and corrects some weaknesses in the earlier version, which is implemented as`gsl_rng_knuthran`

.

__Generator:__**gsl_rng_borosh13**__Generator:__**gsl_rng_fishman18**__Generator:__**gsl_rng_fishman20**__Generator:__**gsl_rng_lecuyer21**__Generator:__**gsl_rng_waterman14**These multiplicative generators are taken from Knuth's Seminumerical Algorithms, 3rd Ed., pages 106–108. Their sequence is, where the seed specifies the initial value,

*x_1*. The parameters*a*and*m*are as follows, Borosh-Niederreiter:*a = 1812433253*,*m = 2^32*, Fishman18:*a = 62089911*,*m = 2^31 - 1*, Fishman20:*a = 48271*,*m = 2^31 - 1*, L'Ecuyer:*a = 40692*,*m = 2^31 - 249*, Waterman:*a = 1566083941*,*m = 2^32*.

__Generator:__**gsl_rng_fishman2x**This is the L'Ecuyer–Fishman random number generator. It is taken from Knuth's Seminumerical Algorithms, 3rd Ed., page 108. Its sequence is, with

*m = 2^31 - 1*.*x_n*and*y_n*are given by the`fishman20`

and`lecuyer21`

algorithms. The seed specifies the initial value,*x_1*.

__Generator:__**gsl_rng_coveyou**This is the Coveyou random number generator. It is taken from Knuth's Seminumerical Algorithms, 3rd Ed., Section 3.2.2. Its sequence is, with

*m = 2^32*. The seed specifies the initial value,*x_1*.

[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |