Thus we choose m 211 2 048 so that with period 512 we

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: call that when m is a power of two and c = 0, the full period is m=4, but only if a 3 mod 8 or a 5 mod 8. Thus we choose m = 211 = 2 048 so that with period 512, we plot almost the same number of points (508) as we see in Figures 6a-c. Figure 6d illustrates the result of using a good choice of a (a = 269 5 mod 8). As in the prime modulus case, the plotted points form a uniform looking lattice. But when we plot the points in Figure 6e generated by taking a = 1 203 3 mod 8, we see that the pattern looks like two lattice structures slightly o set from one another. This double lattice distinguishes the a 3 mod 8 case from the a 5 mod 8 case and is the reason that a 5 mod 8 is preferred, even though both sets of a values produce the same period. As an aside, the two lattice structures in the a 3 mod 8 case come about from plotting separately the pairs beginning with odd indices and those beginning with even indices. The cases looked at so far are for moduli chosen to be small enough that we can plot the full-period results and still see a pattern with space between points. In practice, it would be foolish to use a generator with such a short period. If we look at an LCG with much longer period, one that we might use in a practical application, we still see the lattice-like full-period behavior. Figure 6f shows the full-period 2-D result for LCG(16807 0 231 ; 1 1), where we \zoom in" on only the portion of the unit square in the (0,0.0005) X (0,0.0005) corner, or 1/4,000,000 of the total area. Although the row spacing for this generator is obviously not optimal, this particular one is popular for its universal portability and its satisfactory performance in many applications. We have shown only examples in which c = 0. Using a nonzero value for c when m is prime has the e ect of shifting the entire lattice structure to a new location, so that it appears o set from that of the c = 0 case. The orientation and spacing of the lattice remain the same, except that one lattice point appears absent | this re ects the fact that when m is prime and c = 0, some nonzero value of X will succeed itself in the recursion formula of the generator. (Actually, there is a \hole" in the c = 0 lattice as well, but it lies on one of the axes, and so doesn't disrupt the apparent regularity.) When m is a power of two and c is nonzero, recall that the period of the generator is four times the period of the c = 0 case. Here again the resulting lattice appears to be aligned the same as the c = 0 lattice, with the c = 0 lattice o set from a subset of the c 6= 0 lattice. A further complication arises in the case where m is a power of two and a 3 mod 8: here a nonzero value for c will produce di erent o sets for each of the two distinct lattice structures, relative to the c = 0 case. The Remarks 25 fact that the c 6= 0 case is slightly more complicated than the c = 0 case should not obscure the basic theme of this section: that the quality of an LGC used in generating n-tuples is a function of the multiplier, a. The remarks given here with respect to 2-D behavior of LCGs apply as well to higher dimensions. For example, in three dimensions, the coordinate triples (R1 R2 R3) formed as above will lie in distinct planes. For ease of illustration, we have considered only 2-D examples and only in a qualitative sense. The lattice spacing in any number of dimensions can be treated quantitatively using methods detailed in Knuth, Vol. 2. The interested reader is encouraged to pursue the topic further in this source. Remember that the e ects described here are full-period properties of LCGs. If only a tiny fraction of the period is used, the most desirable way to use any pseudo-random generator, then these e ects may not be noticed. If a user suspects that the lattice structure of n-tuple generation is a ecting the outcome of a Monte Carlo simulation, then the best policy is to try another generator of di erent type and compare the results. Exercise 7 - visualization of some poor LCGs Modify the ranlc.f code to output (x y) pairs of numbers as (R1 R2), (R2 R3), (R3 R4), etc. Plot these discrete points for the following cases: (a) a = 66, c = 0, m = 231, 4,095 points (4,096 random numbers) (b) a = 5, c = 0, m = 231 ; 1, 4,095 points (4.096 random numbers) 5 Vectorization and Access via Multiple Processors: LCGs Many Monte Carlo applications have characteristics that make them easy to map onto computers having multiple processors. Some of these parallel implementations require little or no interprocessor communication (such applications are called \embarrassingly parallel") and are typically easy to code on a parallel machine. Others require frequent communication and synchronization among processors and in general are more di cult to write and debug. In developing any parallel Monte Carlo code, it is important to be able to reproduce runs exactly in order to trace program execution. Processors in MIMD machines are subject to asynchronous and unbalanced...
View Full Document

This document was uploaded on 01/28/2014.

Ask a homework question - tutors are online