Portable Random Number Generators

Gerald P. Dwyer Jr. and K.B. Williams
Federal Reserve Bank of Atlanta
Working Paper 99-14
October 1999

Download the full text of this paper (582 KB) PDF icon

Computers are deterministic devices, and a computer-generated random number is a contradiction in terms. As a result, computer-generated pseudorandom numbers are fraught with peril for the unwary. We summarize much that is known about the most well-known pseudorandom number generators: congruential generators. We also provide machine-independent programs to implement the generators in any language that has 32-bit signed integers-for example C, C++, and FORTRAN. Based on an extensive search, we provide parameter values better than those previously available.

JEL classification: C15

Key words: random number generators, congruential generators, Monte Carlo

An earlier version of this paper was presented at the Society for Computation Economics meeting in 1997, and the authors thank the participants for helpful comments. They also thank Stephen L. Moshier, who kindly provided many underlying routines used in the programs and helpful comments. The computer code and detailed tables are available from either author. The views expressed here are the authors' and not necessarily those of the Federal Reserve Bank of Atlanta or the Federal Reserve System. Any remaining errors are the authors' responsibility.

Please address questions regarding content to Gerald P. Dwyer Jr., Research Department, Federal Reserve Bank of Atlanta, 104 Marietta Street, NW, Atlanta, Georgia 30303-2713, 404/498-7095, 404/498-8810 (fax), gerald.p.dwyer@atl.frb.org (or dwyerg@clemson.edu); or K.B. Williams, 412 Magnolia Avenue, Melbourne Beach, Florida 32951-2000, kbwms@aol.com.