Random number generator

The ranlux generator is based on a dynamical system which may be regarded as a multi-dimensional version of Arnold's famous cat map. Similarly to the cat map, the system can be proved to be chaotic in a strong sense. A theoretical understanding of the randomness of the generated sequence of numbers is thus obtained. The generator has an astronomical period and is well suited for large-scale Monte Carlo simulations.


The basic algorithm (a subtract-with-carry Fibonacci recurrence) was introduced by Marsaglia and Zaman in 1991. It was rapidly noted, however, that the random number sequences produced by this algorithm do not pass simple empirical tests of randomness such as the gap test.

Later the algorithm was shown to be related to a strongly chaotic dynamical system. The Lyapunov exponents of the latter set the time scales for statistical correlations in the generated random sequences. In particular, subsequences of numbers separated by several correlation times are highly decorrelated and thus provide a much better source of (pseudo) random numbers.

All this is explained in detail in

    M. Lüscher, A portable high-quality random number generator for lattice field theory simulations,
    Computer Physics Communications 79 (1994) 100  ( Science DirectarXiv.org).

A Fortran 77 implementation of the generator was developed by Fred James shortly after this paper appeared. James also introduced the name ranlux for the generator and the term luxury level for the fraction of numbers discarded from the basic sequence. Both single- and double-precision implementations of ranlux are included in the GNU Scientific Library and the C++ standard library.

The algorithm of Marsaglia and Zaman can be mapped, in a one-to-one fashion, to a linear congruential generator with huge modulus and multiplier. As explained in a paper by Alexei Sibidanov ( Science DirectarXiv.org), this representation permits the generator to be accelerated at high luxury levels. Contrary to what its name suggests, the implementation published with the paper, RANLUX++, however does not natively deliver the same numbers as ranlux, for no choice of the parameters and seeds.

The ranlux generator is widely used in Monte Carlo simulation programs. Such simulations are often performed on parallel computers, where each MPI process runs a private copy of the generator (with different seeds).


The package ranlux-3.4.tar.gz contains an efficient C code that implements both the single- and the double-precision version of the generator. The package includes various utility programs, the implementation notes Algorithms used in ranlxs and ranlxd v3.4 and the User's guide for ranlxs and ranlxd v3.4. With respect to the previous version, ranlux-3.3.tar.gz, the code has been significantly restructured so as to be better adapted to 64 bit machines. While the new code is typically 2 to 4 times faster, the function prototypes and the generated sequences of random numbers are the same.


The software may be used under the terms of the GNU General Public Licence (GPL).

Last updated 30 May 2021