Some Uniform and Normal Random Number Generators

xorgens

xorgens is a collection of uniform random number generators
written in C and returning 32 or 64-bit integer or real values.
The generators use a generalisation of Marsaglia's "xorshift"
random number generators
[218, 224].
They are fast, appear to be good,
and have periods greater than 101200.

The source code of version 3.05 is available
here (xorgens305.tar.gz) and
here (xorgens305.zip).
The theory is described in my paper [224].
The only difference between versions 3.04 and 3.05 is a small correction
to the comments (thanks to G. Weijers for this).

xorgens has been tested using various statistical tests and appears
to be satisfactory. However, we recommend that you do your own tests.

If you want to experiment with different sets of parameters, a short
table of possibilities is available
here (xortable.txt, 2K). Note that the code assumes that r is
a power of two, so some small changes are required if this is not the case.
We do not recommend the generators with n < 256 because their
state space is too small.

ranut

ranut is a uniform pseudo-random number generator which uses
recurrences based on
primitive trinomials, or in some cases trinomials which have
large primitive factors (over the field GF(2)).
It is written in Fortran 77 and is optimised to run efficiently
on vector processors, but also works well on other machines with IEEE
Standard 64-bit floating-point arithmetic. The recurrences are implemented
directly in floating-point to generate real numbers in [0,1], rather than
integers.

ranut has been tested using George Marsaglia's
Diehard package
and appears to be satisfactory. However, we recommend that you do your own
tests and, if necessary, combine the output of ranut with that of an
independent random number generator.

ranut is based on an earlier generator RANU4 (1991) which is
described in [132].

Nowadays I prefer xorgens to ranut since generators based
on primitive trinomials have some theoretical weaknesses. However, the
trinomials used in ranut have such high degree that these
weaknesses are probably insignificant in practice.

rannw

rannw is a Fortran 77 pseudo-random number generator which uses
a variant of Chris Wallace's method to generate normally distributed
(i.e. Gaussian) numbers.

Most algorithms for generating normally
distributed random numbers are slow
because they first generate uniformly distributed numbers and
then transform them to normally distributed numbers.
rannw is potentially faster because it generates normally distributed
numbers directly, without using uniformly distributed numbers
(except occasionally, for initialisation etc).

rannw has been tested using Marsaglia's Diehard package
and appears to be satisfactory. (Because Diehard is designed to test
uniformly distributed numbers, the output of rannw was transformed
appropriately before input to Diehard.)

rannw is based on an earlier generator RANN4 which is
described in
[170,
185].

Wallace's own implementation of his method (written in C) is available
here.

Availability - the random package

ranut and rannw are available
in the random package
(free, but with absolutely no warranty)
as open-source software under the
GNU General Public License.

A gzipped tar file of random version 1.03 is available
here (48 KB).
There is also a
zip file (55 KB).
The distribution contains the Fortran source code, test programs,
output obtained from testing with Diehard, etc.