{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

E not cyclical shifts of one another sequences are

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: tor LCG(5 0 16 X0 ), generate all the possible sequences by varying the initial seed from 0 and 15. How many independent (i.e. not cyclical shifts of one another) sequences are there? Is there a pattern observable in even versus odd integers? Discuss possible reasons for this behavior. 20 Exercise 6 - Cray's LCG ranf() On a Cray supercomputer running UNICOS, obtain the manual page on its intrinsic random number generator by typing at the UNICOS prompt (%) \man ranf > ranf.doc". Read the le ranf.doc to see how to set and get the seed for ranf. Given that ranf is a multiplicative, congruential generator (c = 0) using 46 bits - get the initial seed discuss it in terms of cycle length. Set the seed to 1, and call ranf to obtain a new seed. Get and print out the new seed this new seed is the multiplier of the generator. Discuss the multiplier in the context of the cycle length. Print out the rst ten random integers in decimal and hexadecimal format, and the corresponding random real numbers using an f20.16 format. 4 N-tuple Generation With LCGs Suppose we wanted to choose random locations in the unit square for Monte Carlo trials in an application program. A very easy way to choose these points is to select two random values, R1 and R2, in 0,1) and choosing the point (R1 R2) as the current point of interest in the square. More generally, we would generate a point by plotting Rn+1 vs. Rn, where Rn and Rn+1 are of course obtained by scaling successive outputs, Xn and Xn+1 , of the generator LCG(a c m X0) by 1=m. If we repeat this procedure for a large number of trials, we would like to expect that we will achieve a reasonably good \covering" of the unit square and in a \randomly" ordered fashion. We would be suspicious of a generator that produced points in the square that were, say, clustered in the bottom half, or perhaps covered the square in some clear order from left to right. Many other forms of obvious nonrandom behavior would be equally unacceptable for most Monte Carlo applications. A characteristic of LCGs is that points selected in this way and plotted in the unit square begin to form regular-looking rows or dotted lines that are easily discernible when enough points have been plotted and when viewed at the proper scale. Over the entire period of an LCG, if all consecutive pairs are plotted, then these rows ll in to become evenly spaced between points. This constitutes one of the well known tests of randomness applied to pseudo-random number generators - the so-called spectral test, the object of which is to discover the behavior of a generator when its ouputs are used to form n-tuples. The formal development of this family of tests is di cult and we will not cover it here (the interested reader is referred to Knuth), but we will attempt to illustrate through several examples the meaning of the concept as it applies to a 2-dimensional setting and with linear congruential generators. The concepts presented are valid in higher dimensions as well. In Figure 6a-f we present a few examples to illustrate this behavior. These examples depict the result of generating all pairs of consecutive numbers in the period of full-period LCGs. For each modulus, the plotted points show the e ect of our choice of the multiplier, a. In Figure 6a we show the set of points produced by scaling by 1/509 the output of the generator LCG(10 0 509 1). Note that the points form more than one set of rows. That is, there are several angles from which the points appear to line up. From some perspectives, the rows are close together, while from at least one perspective, the rows are rather far apart. Remarks 1.0 R(n+1) 0.5 0.0 0.0 0.5 R(n) 1.0 Figure 6: (a) Pair Plot of LCG(10,0,509,1) 1.0 R(n+1) 0.5 0.0 0.0 0.5 R(n) Figure 6: (b) Pair Plot of LCG(128,0,509,1) 1.0 21 22 1.0 R(n+1) 0.5 0.0 0.0 0.5 R(n) 1.0 Figure 6: (c) Pair Plot of LCG(108,0,509,1) 1.0 R(n+1) 0.5 0.0 0.0 0.5 R(n) Figure 6: (d) Pair Plot of LCG(269,0,2048,1) 1.0 Remarks 1.0 R(n+1) 0.5 0.0 0.0 0.5 R(n) 1.0 Figure 6: (e) Pair Plot of LCG(1203,0,2048,1) 0.00050 R(n+1) 0.00025 0.00000 0.00000 0.00025 R(n) Figure 6: (f) Pair Plot of LCG(16807,0,2147483647,1) 0.00050 23 24 The best situation is to have the maximum spacing of the rows, when viewed over all angles, as small as possible. When the maximum spacing is large, as it certainly is in Figure 6b, LCG(128 0 509 1), then clearly the unit square is not well covered by this set of points, and the results of our simulation may be adversely a ected by this \striping." Figure 6c shows the e ect of a good choice of a, LCG(108 0 509 1), for which the maximum spacing between rows is clearly smaller than it is in the rst two cases, and where the points cover the unit square with nearly optimal uniformity, given that with this generator we can generate only a small number of points. Figures 6a-c are examples that all use the prime modulus m = 509. When m is a power of two, the other major case to consider, the situation is similar, as depicted in Figures 6d and e. Re...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online