A Portable Uniform Random Number Generator Well Suited for the Rejection Method

Wolfgang Hörmann and Gerhard Derflinger


Up to now all known efficient portable implementations of linear congruential random number generators with modulus $2^{31}-1$ are working only with multipliers which are small compared with the modulus. We show that for non-uniform distributions, the rejection method may generate random numbers of bad quality if combined with a linear congruential generator with small multiplier. Therefore a method is described that works for any multiplier smaller than $2^{30}$. It uses the decomposition of multiplier and seed in high order and low order bits to compute the upper and the lower half of the product. The sum of the two halfs gives the product of multiplier and seed modulo $2^{31}-1$. Coded in ANSI-C and FORTRAN77 the method results in a portable implementation of the linear congruential generator that is as fast or faster than other portable methods.

Mathematics Subject Classification: 65C10 (Random Number Generation)

CR Categories and Subject Descriptors: G.3 [Probability and Statistics]: Random number generation

General Terms: Algorithms

Key Words: uniform random number generator, linear congruential generator, portability, rejection method, quality of non-uniform random numbers

Download Preprint
© ACM, (1992). This is the author's version of the work. It is posted here by permission of ACM for your personal use. Not for redistribution. The definitive version was published in Trans. Math. Softw. 19(4), 489-495. http://doi.acm.org/10.1145/168173.168414