10.12.2012 Views

Prime Numbers

Prime Numbers

Prime Numbers

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

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

}<br />

return x; // New random number.<br />

Thanks to the shifts and “and” operations, this algorithm involves no explicit<br />

multiplication or division. Furthermore, the generator fares well under some<br />

established statistical tests [Wu 1997]. Of course, this generator can be<br />

generalized, yet as with any machine generator, caution should be taken in<br />

choosing the parameters; for example, the parameters c, M should be chosen<br />

so that c is a primitive root for the prime M to achieve long period. We<br />

should also add an important caution: Very recent experiments and analyses<br />

have uncovered weaknesses in the generator of the type in Algorithm 8.2.3.<br />

Whereas this kind of generator evidently does well on spectral tests, there<br />

are certain bit-population statistics with respect to which such generators<br />

are unsatisfactory [L’Ecuyer and Simard 1999]. Even so, there are still good<br />

reasons to invoke such a generator, such as its very high speed, ease of<br />

implementation, and good performance on some, albeit not all, statistical<br />

tests.<br />

Variants to these congruential generators abound. One interesting development<br />

concerns generators with extremely long periods. A result along such<br />

lines concerns random number generation via matrix–vector multiplication.<br />

If T is a k × k matrix, and x a k-component vector, we may consider the<br />

next vector in a generator’s iteration to be x = Tx, say,withsomerulefor<br />

extracting bits or values from the current vector.<br />

Theorem 8.2.4 (Golomb). For prime p, denote by Mk(p) the group of<br />

nonsingular k × k matrices (mod p), andletx be a nonzero vector in Z k p.<br />

Then the iterated sequence<br />

x, Tx, T 2 x, ...<br />

has period p k − 1 if and only if the order of T ∈ Mk(p) is p k − 1.<br />

This elegant theorem can be applied in the same fashion as we have<br />

constructed the previous iterative generators. However, as [Golomb 1982] and<br />

[Marsaglia 1991] point out, there are much more efficient ways to provide<br />

extreme periods. In this case it is appropriate for the key theorem to follow<br />

the algorithm description, because of the iterative nature of the generator.<br />

Algorithm 8.2.5 (Long-period random generator).<br />

This algorithm assumes input integers b ≥ 2 and r>s>0 and produces an<br />

iterative sequence of pseudorandom integers, each calculated from r previous<br />

values and a running carry bit c. We start with a (vector) seed/carry entity v with<br />

its first r components assumed in [0,b− 1], and last component c =0or 1.<br />

1. [Procedure seed]<br />

seed() {<br />

Choose parameters b ≥ 2 and r>s>0;

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

Saved successfully!

Ooh no, something went wrong!