1.1. AN APPROXIMATE UNIFORM DENSITY 7
In numerical analysis, although we may not be able to deal with the num-
bers in the interval (1 − b
−p
, 1), we do expect to be able to deal with numbers
in the interval (0,b
−p
), which is of the same length. (This is because, usually,
relative differences are more important than absolute differences.) A random
variable such as X above, defined on the computer numbers with e = 0, is not
adequate for simulating a U(0, 1) random variable. Although the density of
computer numbers near 0 is greater than that of the numbers near 1, a good
random number generator will yield essentially the same proportion of numbers
in the interval (0,k) as in the interval (1−k, 1), where k is some small number
such as 3 or 4, and = b
−p
, which is a machine epsilon. (The phrase “machine
epsilon” is used in at least two different ways. In general, the machine epsilon
is a measure of the relative spacing of computer numbers. This is just the
difference between 1 and the two numbers on either side of 1 in the set of com-
puter numbers. The difference between 1 and the next smallest representable
number is the machine epsilon used above. It is also called the smallest relative
spacing. The difference between 1 and the next largest representable number
is another machine epsilon. It is also called the largest relative spacing.) If
random numbers on the computer were to be generated by generating the com-
ponents of equation (1.2) directly, we would have to use a rather complicated
joint distribution on e and the ds.
Modular Arithmetic
The standard methods of generating pseudorandom numbers use modular re-
duction in congruential relationships. There are currently two basic techniques
in common use for generating uniform random numbers: congruential methods
and feedback shift register methods. For each basic technique there are many
variations. (Both classes of methods use congruential relationships, but for his-
torical reasons only one of the classes of methods is referred to as “congruential
methods”.)
Both the congruential and feedback shift register methods use modular arith-
metic, so we now describe a few of the properties of this arithmetic. For more
details on general properties, the reader is referred to Ireland and Rosen (1991),
Fang and Wang (1994), or some other text on number theory. Zaremba (1972)
and Fang and Wang (1994) discuss several specific applications of number the-
ory in random number generation and other areas of numerical analysis.
The basic relation of modular arithmetic is equivalence modulo m, where m
is some integer. This is also called congruence modulo m. Two numbers are
said to be equivalent, or congruent, modulo m if their difference is an integer
evenly divisible by m.Fora and b, this relation is written as
a ≡ b mod m.
For example, 5 and 14 are congruent modulo 3 (or just “mod 3”); 5 and −1 are
also congruent mod 3. Likewise, 1.33 and 0.33 are congruent mod 1. It is clear
from the definition that congruence is