Version 3.14, Rev. December 31, 1992, C. Puig

**Random Number Generator Algorithm**

NOTE: In this section, the symbol “^” is used to denote exponentiation. For example, 2^15 means “two to the fifteenth power.”

7.1 Basic Random Number Generator Random() (Rel. 3.11)

All random numbers produced by Resampling Stats are derived a single basic random number generator, implemented as the macro Random() declared in runtime.h. The basic generator uses a multiplicative linear congruential algorithm based on the following generating function:

f(s) = (a * s) mod m (eq. 7-1) where a = 16807 = 7^5, and m = 2147483647 = 2^31 - 1.

This algorithm is discussed at length in:

Stephen K. Park and Keith W. Miller, “Random Number Generators: Good Ones Are Hard to Find,” Communications of the ACM, 31:10 (October, 1988), 1192-1201.

Park and Miller called this the “minimal standard generator” for reasons explained in the paper. The Resampling Stats implementation is a C translation of Park and Miller’s “Real Version 1” (p. 1195), using the C library function fmod to carry out the “mod” operation in the definition of the generating function.

The resulting generator has a period of m-1, since 0 is excluded from the generated series. Real-valued random numbers in the open interval (0,1) (not including the endpoints) are generated as the quotient s/m, where s is the seed. Random() returns this real-valued quotient.

This algorithm may be initialized with any integer seed value from 1 to m-1, inclusive. Note that 0 is not a legal seed value (since f(0) = 0). If the user does not specify an initial seed value via the SEED command, Resampling Stats uses the system time of day (in seconds since January 1, 1970) to initialize the seed. This initialization is carried out only once per Resampling Stats session, right after Resampling Stats is invoked. This operation is equivalent to invoking the SEED command with the value returned by the time() function in the C library. See the description of the SEED command for a discussion of the seeding operation.

Resampling Stats does not use the random number generator functions in the C compiler library.