Unformatted text preview: (a)
above. Generate plots as above in (a). What do you observe about the uniformity of the
random numbers and their correlation? Remarks
call init175(iseed0)
...
krand = irnd()
krand = irnd()
krand = irnd()
...
c
c
subroutine init175(iseed)
implicit integer (az)
parameter(a = 16807, r = 2836, q = 127773, m = z'7fffffff')
common/c175/ ifibreg(17),lptr,kptr
c
do i=1,16
hi
=
lo
=
iseed
=
if(iseed.lt.0) iseed =
ifibreg(i)
=
enddo
ifibreg(11) = ifibreg(11)
lptr
= 17
kptr
=5
return
end iseed/q
mod(iseed,q)
a*lo  r*hi
iseed + m
ishft(iseed,1)
+1 c
c
integer function irnd175()
parameter(mask32 = z'ffffffff', mask31 = z'7fffffff')
common/c175/ ifibreg(17),lptr,kptr
c
itemp
= ifibreg(lptr) + ifibreg(kptr)
ifibreg(lptr)
= iand(itemp,mask32)
lptr
= lptr  1
kptr
= kptr  1
if(lptr.le.0) lptr = 17
if(kptr.le.0) kptr = 17
irnd175
= iand(ishft(itemp,1),mask31)
return
end Figure 13 FORTRAN implementation of LFG(17 5 32) 39 40 Exercise 11  the fundamental concepts of LFGs Consider the Fibonacci generator LFG(3 2 2).
(a) Draw a shift register diagram, similar to Figure 10, to represent , the action of this
generator.
(b) How long is the period, P , of this generator?
(c) How many distinct cycles does this generator have?
(d) Using the information for this generator in Table 4, initialize, in canonical form, every
cycle for this generator, and generate each full cycle.
(e) Suppose the generator LFG(3 2 2) were initialized with the values, X1 = 1, X2 = 3,
and X3 = 1. If the generator were advanced for a full cycle, which of the \canonical" cycles
generated in part (d) would be the same as this new one? How many advances of the
generator did you need to determine this?
(f) Would parts (a) through (e) be fun to do if the generator changed only slightly, from
LFG(3 2 2) to LFG(3 2 3) ? What is the value of P for LFG(3 2 3)? How many distinct
cycles does it have? Exercise 12  various LFGs as they in uence the number and
length of cycles Using a computer and your favorite programming language, go through steps (a) through (e)
as in Exercise 11, above, for the generator LFG(5 3 2). What about part (f), i.e., changing
LFG(5 3 2) to LFG(5 3 3)? What would that change do to the number of cycles and to
P? 7 Summary and Recommendations
We have illustrated through example applications the implementation of various random
number generators. We have concerned ourselves much more with issues of portability and
quality than with e ciency, as our observations have been that generating random numbers
is not very consumptive of CPU resources, except in a narrow range of circumstances. Our
observations have led us to conclude that, now, due to more powerful computers, more
sophisticated physical models are employed. This results in codes which do more work per
random trial than in the past.
Although this is not a formal treatment, we have been able to infer that there exist good
random number generators for 32 bit machines. The portable generator recommended by
Park and Miller Park and Miller, 1988] appears to be particularly suitable for \ordinary"
problems. At very large scale, this random number generator's period of 231 ; 2 (over 2
billion) may be too short.
Using lagged Fibonacci generators shows great promise, and is now undergoing thorough
testing  particularly in terms of correlations of sequences. It appears particularly suitable
for generating many streams of independent random numbers in parallel. The interested Remarks 41 reader should \stay tuned" for further developments. Moreover, we believe these generators
are now su ciently mature that we recommend them for inclusion in existing applications.
The quality of the random sequences are at least as good as those generated using LCGs,
with the only drawback being the requirement for greater storage. In cases requiring many
parallel generators, this can be a factor.
Finally, we wax philosophical. We urge the supercomputist to approach the generation of
random numbers with circumspection, particularly when solving very largescale problems.
All random number generators should be tested thoroughly for their quality before being
used upon other than academic problems. Further, at least two levels of quality in random
number generators should be implemented to assess whether the answers are independent of
the random numbers. This is a matter requiring judgment and is aided by experience.
However, the situation is not as bleak as it may seem from the above discussion. For very
large scale problems lacking a regular structure (e.g., complex geometries and/or material
properties), it is very unlikely that correlations between random numbers generated on separate processors will be signi cant due to the fact that the physical problem exhibits a great
many possibilities for random events. Further, if the parameters of the generator are chosen
correctly, there are a great many possibilities for random events when using random real
numbers. However, the truly cautious researcher should not rely on the con uence of these
fact...
View
Full Document
 Fall '14
 Randomness, random number, Pseudorandom number generator, congruential generators, LCGs

Click to edit the document details