10.12.2012 Views

Prime Numbers

Prime Numbers

Prime Numbers

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

398 Chapter 8 THE UBIQUITY OF PRIME NUMBERS<br />

8.2.1 Modular methods<br />

The veritable workhorse of the random number generation industry has been<br />

the linear-congruential generator. This method uses an integer iteration<br />

xn+1 =(axn + b) modm,<br />

where a, b, m are integer constants with m > 1, which recursion is to be<br />

ignited by an initial “seed,” say x0. To this day there continue to appear<br />

research results on the efficacy of this and related generators. One variant is<br />

the multiplicative congruential generator, with recursion<br />

xn+1 =(cxn) modm,<br />

where in this case the seed x0 is assumed coprime to m. In applications<br />

requiring a random() function that returns samples out of the real interval<br />

[0, 1), the usual expedient is simply to use xn/m.<br />

Recurrences, like the two above, are eventually periodic. For random<br />

number generation it is desirable to use a recursion of some long period. It is<br />

easy to see that the linear-congruential generator has period at most m and<br />

the multiplicative congruential generator has period at most m−1. The linear<br />

case can—under certain constraints on the parameters—have the full period<br />

m for the sequence (xn), while the multiplicative variety can have period<br />

m − 1. Fundamental rules for the behavior of such generators are embodied<br />

in the following theorem:<br />

Theorem 8.2.1 (Lehmer). The linear-congruential generator determined<br />

by<br />

xn+1 =(axn + b) modm<br />

has period m if and only if<br />

(1) gcd(b, m) =1,<br />

(2) p|a − 1 whenever prime p|m,<br />

(3) 4|a − 1 if 4|m.<br />

Furthermore, the multiplicative congruential generator determined by<br />

has period m − 1 if and only if<br />

(1) m is prime,<br />

(2) c is a primitive root of m,<br />

(3) x0 ≡ 0(modm).<br />

xn+1 =(cxn) modm<br />

Many computer systems still provide the linear scheme, even though there are<br />

certain flaws, as we shall discuss.<br />

First we give an explicit, standard linear-congruential generator:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!