NE582 Monte Carlo
|
Lesson 3: Pseudo-Random NumbersThis lesson is the one and only lesson in this course that has to do with the INPUT to the "black box" introduced in Lesson 2:
As implied by the figure, these form the material from which every Monte Carlo method creates its answer. And, as with any human enterprise, the quality of the inputs has a strong influence on the quality of the outputs. In the early days of Monte Carlo (the 40s and 50s), it was common for researchers to suggest physical devices--based on truly random physical phenomena such as nuclide decay--to generate truly random numbers. As computers have gotten faster and faster, this has gotten less and less feasible. (For nuclide decay for example, we need to DETECT about 50 particles for each random number generated. If we were to try to keep up with a 1 gigaHz clock speed at, say, a 10% counting efficiency, we would need a (50 particles detected/random number)*(1.e9 numbers/sec needed)/(10% counting efficiency) ~= 10 curie source! The most common sources of "random" numbers nowadays are the pseudo-random numbers (which can be designed to be "random enough"). Pseudo-random number generationLinear congruential generatorsFor the most part, the reading in the Numerical Recipes book (which I recommend you get a copy of if you plan to do much computational work in your career) covers the material well. With the homework problem P-1, I think you should have covered all of this subject that we want to.Here are the principal ideas that I want you to remember:
which makes 1 impossible, but 0 possible.
There are "tricks" that can help you alleviate some of the problems, such as "warming up" a generator and/or reshuffling the numbers in "packages". Extending the period using more than one generatorOne consequence of use of the linear congruential generators is that no more than m random numbers can be generated before the series begins to repeat; a second consequence is that m has to less than or equal to the largest integer that the computer can handle (since you have to do arithmetic on the computer using it). Together, these tell us that we can have periods of no more than the largest integer that the computer can handle, which isFortunately, you can get around this limitation by combining the results of several generators. If you use N different generators, add the N random numbers, and keep the fractional part, the resulting random number is properly distributed and the series has a period equal to the PRODUCT of the periods of the N generators. For example, the FORTRAN subroutine used to get a (double precision) random number for the KENO and MORSE computer codes at ORNL is the following: Close examination of this coding reveals that it uses 3 linear congruential generators (with b=0, m=prime number, and period=m). The individual generators have periods of about 32000 (which makes them usable for 16-bit integer computer systems), but combined they have a limiting period of over 3xE13, which should be large enough for any (present-day) application. Quasi-random number generationIn addition to the pseudo-random sequences, another family of "random numbers" that can be used (with appropriate care) to feed our Monte Carlo process are the quasi-random numbers. I left them for the end of the lecture because:1. They are not really random, so they have to be used very carefully.
But, because they are of such importance to the general field of Monte Carlo (i.e., beyond transport methods), you should have a taste of what they are, how to get them, and what they are useful for. "Quasi"-random numbers are not random at all; they are a deterministic, equal-division, sequence that are "ordered" in such a way that they can be used by Monte Carlo methods. The easiest to generate are Halton sequences, which are found by "reflecting" the digits of prime base counting integers about their radix point. Clear as mud, right? A simple example makes it perfectly clear how to do it. Okay. You pick a prime number to be the base (e.g., 2).
You then simply count in that base, like the first two columns below:
The third column shows what we mean by "reflecting" the number. When translated back to base 10, it becomes the next random number in the sequence. If you follow the formula, you can see that after M=2^N-1 numbers in the sequence, the sequence consists of the equally spaced fractions (i/(M+1), i=1,2,3,...M). Therefore, the sequence is actually deterministic, not stochastic. The beauty of the sequence is that the re-ordering results in the an even coverage of the domain (0,1) even if the number of random numbers chosen does not correspond to 2^N-1. Because you need ALL of the numbers in the sequence to cover the (0,1) range (which is not true of the pseudo-random sequence), it is important that all of the numbers of the sequence be used on the SAME decision. For a Monte Carlo process that has more than one decision, a different sequence must be used for each decision. The most common way this situation is handled is to use each of the low prime numbers in order--i.e., use the sequence based on 2 for the first decision, the one based on 3 for the second, then 5, 7, 11, etc. for the subsequent decisions. For reference, here is a subroutine that delivers the Halton sequence
for base 2:
function rand2(r)
rand2 1
You can adapt it to other bases by changing the name and the "2" to
the new base in lines 9 and 10. Normally, one would reset the sequence
by passing any argument OTHER than 0 to the function; thereafter, passing
0 gets the next number in the sequence.
Pseudo or Quasi?Well? Which should we use: pseudo-random or quasi-random? Most Monte Carlo particle transport methods that you will encounter have already made the decision for you, and most of them use pseudo-random. The reason for this is that particle transport problems are, to the Monte Carlo theorist, INFINITE dimensional problems. Before we can understand what this means and why this gives pseudo-random numbers the edge for our transport problems, we need to define a few terms.Dimension, Hypercubes, and DiscrepancyHere are the definitions and a brief discussion about each of these important terms AS USED in Monte Carlo.Dimension: The number of random numbers used for each estimate obtained. Since this is a different meaning of the word "dimension" than we usually see, let's examine it a little closer. We began the course by saying that a Monte Carlo method consists of two steps. The first step was to design a numerical experiment and the second was to run it. No matter how revolutionary, innovative, etc., we are in the first step, the second looks the same: We "draw out" a certain number of random numbers and, from them, produce a single number as the resulting estimate of whatever we are looking for. The process is mathematically indistinguishable from estimating the average value of a function f(x1,x2,x3,...,xN) of N dimensions, each dimension having a domain (0,1). This is best seen in a example. The example is applicable to every Monte Carlo process. All them turn a set of random numbers into estimates, so all of them are equivalent to multi-dimensional functions. And the ANSWERS to the Monte Carlo processes are averages of the estimates, so correspond to integrations of the functions. Of course, the number of dimensions corresponds to the number of random numbers used to get the answer. We can actually say a little more than this, because each of the dimensions are integrated from 0 to 1, so the functions are defined on a hypercube, which is a multidimensional domain where each dimension is bounded by 0 and 1. Our final new term to introduce is that of the discrepancy of a sequence of random points in a hypercube (i.e., the random numbers used to get all of the estimates that go into making our Monte Carlo answer). Discrepancy is just a quantitative measue of how evenly the random points COVER the hypercube. [Other concepts covered in slides but not yet introduced into lecture: offsetting, Koksma-Hwalka theorem, error bounds on Halton.] |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Return to Course Outline © 2005 by Ronald E. Pevey. All rights reserved. |