Monte Carl0 Method: Eckhardt

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

Monte Carlo

and the MONTE CARL0 METHOD


by Roger Eckhardt
combinatorial calculations, I wondered in mathematics, but he was taken by

T
he Monte Carlo method is a sta-
tistical sampling technique that whether a more practical method than the idea of doing such sampling using
over the years has been applied "abstract thinking" might not be to the newly developed electronic comput-
successfully to a vast number of lay it out say one hundred times and ing techniques. The approach .seemed es-
scientific problems. Although the com- simply observe and count the number pecially suitable for exploring the behav-
puter codes that implement Monte Carlo of successful plays. This was already ior of neutron chain reactions in fission
have grown ever more sophisticated, the possible to envisage with the begin- devices. In particular, neutron multiplica-
essence of the method is captured in some ning of the new era of fast computers, tion rates could be estimated and used to
unpublished remarks Stan made in 1983 and I immediately thought of problems predict the explosive behavior of the var-
about solitaire. of neutron diffusion and other ques- ious fission weapons then being designed.
tions of mathematical physics, and more In March of 1947, he wrote to Rob-
"The first thoughts and attempts I generally how to change processes de- ert Richtmyer, at that time the Theoretical
made to practice [the Monte Carlo scribed by certain differential equations Division Leader at Los Alamos (Fig. 1).
method] were suggested by a question into an equivalent form interpretable He had concluded that "the statistical ap-
which occurred to me in 1946 as I was as a succession of random operations. proach is very well suited to a digital
convalescing from an illness and play- Later. .. [ in 1946, I ] described the idea treatment," and he outlined in some de-
ing solitaires. The question was what to John von Neumann and we began to tail how this method could be used to
are the chances that a Canfield solitaire plan actual calculations." solve neutron diffusion and multiplica-
laid out with 52 cards will come out tion problems in fission devices for the
successfully? After spending a lot of Von Neumann was intrigued. Statis- case "of 'inert' criticality" (that is, ap-
time trying to estimate them by pure tical sampling was already well known proximated as momentarily static config-
Los Alamos Science Special Issue 1987
Fig. 1. The first and last pages of von Neumann's remarkable letter to Robert Richtmyer are shown above, as well as a portion of his tentative
computing sheet. The last illustrates how extensivly von Neumann had applied himself to the details of a neutron-diffusion calculation.

Los Alamos Science Special Issue 1987


Monte Carlo

urations). This outline was the first for- setting up this calculation on the ENIAC. to me, therefore, that this approach will
mulation of a Monte Carlo computation He went on to say that "it seems to me gradually lead to a completely satisfac-
for an electronic computing machine. very likely that the instructions given on tory theory of efficiency, and ultimately
In his formulation von Neumann used a this 'computing sheet' do not exceed the permit prediction of the behavior of all
spherically symmetric geometry in which 'logical' capacity of the ENIAC." He es- possible arrangements, the simple ones as
the various materials of interest varied timated that if a problem of the type he well as the sophisticated ones."
only with the radius. He assumed that had just outlined required "following 100 And so it has. At Los Alamos in 1947,
the neutrons were generated isotropically primary neutrons through 100 collisions the method was quickly brought to bear
and had a known velocity spectrum and [each]. . .of the primary neutron or its de- on problems pertaining to thermonuclear
that the absorption, scattering, and fission scendants," then the calculations would as well as fission devices, and, in 1948,
cross-sections in the fissionable material "take about 5 hours." He further stated, Stan was able to report to the Atomic
and any surrounding materials (such as somewhat optimistically, that "in chang- Energy Commission about the applica-
neutron moderators or reflectors) could be ing over from one problem of this cate- bility of the method for such things as
described as a function of neutron veloc- gory to another one, only a few numeri- cosmic ray showers and the study of the
ity. Finally, he assumed an appropriate cal constants will have to be set anew on Hamilton Jacobi partial differential equa-
accounting of the statistical character of one of the 'function table' organs of the tion. Essentially all the ensuing work on
the number of fission neutrons with prob- ENIAC." Monte Carlo neutron-transport codes for
abilities specified for the generation of 2, His treatment did not allow "for the weapons development and other applica-
3, or 4 neutrons in each fission process. displacements, and hence changes of ma- tions has been directed at implementing
The idea then was to trace out the terial distribution, caused by hydrody- the details of what von Neumann out-
history of a given neutron, using ran- namics," which, of course, would have lined so presciently in his 1947 letter (see
dom digits to select the outcomes of the to be taken into account for an explo- "Monte Carlo at Work").
various interactions along the way. For sive device. But he stated that "I think
example, von Neumann suggested that that I know how to set up this problem,
in the compution "each neutron is rep-
resented by [an 80-entry punched com-
too: One has to follow, say 100 neu-
trons through a short time interval At;
Itronnneutron
von Neumann's formulation of the
diffusion problem, each neu-
history is analogous to a single game
puter] card . . . which carries its character- get their momentum and energy trans- of solitare, and the use of random num-
istics," that is, such things as the zone of fer and generation in the ambient mat- bers to make the choices along the way
material the neutron was in, its radial po- ter; calculate from this the displacement is analogous to the random turn of the
sition, whether it was moving inward or of matter; recalculate the history of the card. Thus, to carry out a Monte Carlo
outward, its velocity, and the time. The 100 neutrons by assuming that matter is calculation, one needs a source of ran-
card also carried "the necessary random in the middle position between its orig- dom numbers, and many techniques have
values" that were used to determine at the inal (unperturbed) state and the above been developed that pick random num-
next step in the history such things as path displaced (perturbed) state;. . . iterating in bers that are uniformly distributed on the
length and direction, type of collision, ve- this manner until a "self-consistent" sys- unit interval (see "Random-Number Gen-
locity after scattering-up to seven vari- tem of neutron history and displacement erators"). What is really needed, how-
ables in all. A "new" neutron was started of matter is reached. This is the treat- ever, are nonuniform distributions that
(by assigning values to a new card) when- ment of the first time interval At. When simulate probability distribution functions
ever the neutron under consideration was it is completed, it will serve as a basis specific to each particular type of de-
scattered or whenever it passed into an- for a similar treatment of the second time cision. In other words, how does one
other shell; cards were started for several interval.. , etc., etc." ensure that in random flights of a neu-
neutrons if the original neutron initiated Von Neumann also discussed the treat- tron, on the average, a fraction e *
a fission. One of the main quantities of ment of the radiation that is generated travel a distance x / \ mean free paths or
interest, of course, was the neutron mul- during fission. "The photons, too, may farther without colliding? (For a more
tiplication rate-for each of the 100 neu- have to be treated 'individually' and sta- mathematical discussion of random vari-
trons started, how many would be present tistically, on the same footing as the neu- ables, probability distribution functions,
after, say, 1 0 " ~second? trons. This is, of course, a non-trivial and Monte Carlo, see pages 68-73 of
At the end of the letter, von Neumann complication, but it can hardly consume "A Tutorial on Probability, Measure, and
attached a tentative "computing sheet" much more time and instructions than the the Laws of Large Numbers.")
that he felt would serve as a basis for corresponding neutronic part. It seems The history of each neutron is gener-

Uis Alamos Science Special Issue 1987


Monte Carlo

3ECISION POINTS g,, and gx Assumed


IN MONTE CARL0 from Initial Conditions

Fig. 2. A schematic of some of the de-


cisions that are made to generate the
"history" of an individual neutron in a
Monte Carlo calculation. The nonuniform
gi Determined from
random-number distributions g used in
Material Properties
those decisions are determined from a
variety of data.

Crossing of
Material Boundary Collision
gr Determined from
Properties of New Material

/\
Crossing of
Material Boundary Collision
/
Scattering Absorption

g,,, Determined from


Scattering Cross Sections g,,,gv;,gv;, . . . Determined
and Incoming Velocity from Fission Cross Sections

ated by making various decisions about els before interacting with a nucleus is unit interval (0,l) into three subintervals
the physical events that occur as the neu- exponentially decreasing, making the se- in such a way that the probability of a
tron goes along (Fig. 2). Associated with lection of shorter distances more proba- uniform random number being in a given
each of these decision points is a known, ble than longer distances. Such a distri- subinterval equals the probability of the
and usually nonuniform, distribution of bution simulates the observed exponen- outcome assigned to that set.
random numbers g that mirrors the prob- tial falloff of neutron path lengths. Simi- In another 1947 letter, this time to Stan
abilities for the outcomes possible for the larly, the distribution of random numbers Ularn, von Neumann discussed two tech-
event in question. For instance, return- gk used to select between a scattering, niques for using uniform distributions of
ing to the example above, the distribu- a fission, and an absorption must reflect random numbers to generate the desired
tion of random numbers g~ used to de- the known probabilities for these differ- nonuniform distributions .g (Fig. 3). The
termine the distance that a neutron trav- ent outcomes. The idea is to divide the first technique, which had already been
Los Alumos Science Special Issue 1987
Monte Carlo

proposed by Stan, uses the inverse of the THE ACCEPTANCE-REJECTION reduction technique. Such techniques
desired function f = g l . For example, METHOD frequently reflect the addition of known
to get the exponentially decreasing distri- physics to the problem, and they reduce
Fig. 4. If two independent sets of random
bution of random numbers on the interval the variance by effectively increasing the
numbers are used. one of which ( x i ) ex-
(0, co) needed for path lengths, one ap- number of data points pertinent to the
tends uniformly over the range of the distri-
plies the inverse function f (x) = - lnx to variable of interest.
bution function f and the other ({) extends
a uniform distribution of random numbers over the domain of f , then an acceptance-
An example is dealing with neutron ab-
on the open interval ( 0 , l ) . rejection technique based on whether or not
sorption by weighted sampling. In this
What if it is difficult or computation- yi < f(x) will generate a distribution for technique, each neutron is assigned a unit
ally expensive to form the inverse func- (2) whose density is f ( x i ) dx'. "weight" at the start of its path. The
tion, which is frequently true when the weight is then decreased, bit by bit at each
desired function is empirical? The rest of collision, in proportion to the absorption
von Neumann's letter describes an alter- cross section divided by the total collision
native technique that will work for such cross section. After each collision an out-
cases. In this approach two uniform and Reject xi since yi > f (xi). come other than absorption is selected by
independent distributions (xi) and fy') are random sampling and the path is contin-
used. A value x i from the first set is ued. This technique reduces the variance
accepted when a value y i from the sec- by replacing the sudden, one-time process
<
ond set satisfies the condition y i f (x'}. of neutron absorption by a gradual elim-
where f ((-')d(- is the density of the de- ination of the neutron.
sired distribution function (that is. g (x) = Another example of variance reduction
ff (x)dx). is a technique that deals with outcomes
This acceptance-rejection technique of that terminate a chain. Say that at each
von Neumann's can best be illustrated collision one of the alternative outcomes
graphically (Fig. 4). If the two numbers terminates the chain and associated with
x i and y i are selected randomly from the this outcome is a particular value xc for
domain and range, respectively, of the the variable of interest (an example is
function f , then each pair of numbers rep- xt being a path length long enough for
resents a point in the function's coordi- Accept x2 since y2 < f(x2). the neutron to escape). Instead of col-
nate plane (xi,yi). When y i > f (xi) the lecting these values only when the chain
point lies above the curve for f (x), and x 1 terminates, one can generate considerably
<
is rejected; when y' f (xi) the point lies more data about this particular outcome
on or below the curve, and x i is accepted. tistical methods identical to those used by making an extra calculation at each
Thus, the fraction of accepted points is to analyze experimental observations of decision point. In this calculation the
equal to the fraction of the area below the physical processes. One can thus extract know value x, for termination is multi-
curve. In fact, the proportion of points se- information about any variable that was plied by the probability that that outcome
lected that fall in a small interval along accounted for in the process. For exam- will occur. Then random values are se-
the x-axis will be proportional to the av- ple, the average energy of the neutrons at lected to continue the chain in the usual
erage height of the curve in that interval, a particular time is calculated by simply manner. By the end of the calculation,
ensuring generation of random numbers taking the average of all the values gen- the "weighted values" for the terminat-
that mirror the desired distribution. erated by the chains at that time. This ing outcome have been summed over all
value has an uncertainty proportional to decision points. This variance-reduction
fter a series of "games" have been ^/V/(N, where V is the variance technique is especially useful if the prob-
A played, how does one extract mean-
ingful information? For each of thou-
of, in this case, the energy and N is the
number of trials, or chains, followed.
ablity of the alternative in question is low.
For example, shielding calculations typi-
sands of neutrons, the variables describ- It is, of course, desirable to reduce sta- cally predict that only one in many thou-
ing the chain of events are stored, and this tistical uncertainty. Any modification to sands of neutrons actually get through the
collection constitutes a numerical model the stochastic calculational process that shielding. Instead of accumulating those
of the process being studied. The collec- generates the same expectation values but rare paths, the small probabilities that a
tion of variables is analyzed using sta- smaller variances is called a variance- neutron will get through the shield on its

Los Alamos Science Special Issue 1987


Monte Carlo

very next free flight are accumulated after


each collision.

he Monte Carlo method has proven


T to be a powerful and useful tool. In
fact, "solitaire games" now range from
the neutron- and photon-transport codes by Tony Warnock
through the evaluation of multi-dimen-
sional integrals, the exploration of the
properties of high-temperature plasmas,
and into the quantum mechanics of sys- rs have applications in many as: simulation, game-playing,
tems too complex for other methods. cryptography, statistical sampling, evaluation of multiple integrals, particle-
transport calculations, and computations in statistical physics, to name a few.
Since each application involves slightly different criteria for judging the "worthiness"
of the random numbers generated, a variety of generators have been developed, each
with its own set of advantages and disadvantages.
Depending on the application, three types of number sequences might prove
equate as m numbers.'' From a purist point of view. of course, a series of
mbers ge a truly random process is most desirable. This type of sequence
a random-number sequence, and one of the key problems is deciding whether
or not the generating process is, in fact, random. A more practical sequence is the
pseudo-random sequence, & series of numbers generated by a deterministic process
that is intended merely to imitate a random sequence but which, of course, does not
rigorously obey such things as the laws of large numbers (see page 69). Finally, a 1
@St-randm sequence is a series of numbers that makes no pretense at being random
but that has important predefined statistical properties shared with random sequences.

Physical Random-Number Generators 1


Games of chance are the classic examples of random processes, and the first
inclination would to use traditional gambling devices as random-number generators.
Unfortunately, these dev are rather slow, especially since the typical computer
application may require ms of numbers per second. Also, the numbers obtained
cards may be imperfectly shuffled,
, and so forth. However, in the early
digit table of random numbers using
slots, of which 12 were ignored; the

only because of our ignorance of initial


terninistic Newtonian physics. Another
1
advantage of the Heisenberg
g decays of a radioactive
h of these methods have been used to
0th suffer the defects of slowness and
order of magnitude than
I
Los Alamos Science Special Issue 1987
Monte Carlo

For instance, although each decay in a radioactive source may occur randomly
and independently of other decays, it is not necessarily true that successive counts in
the detector are independent of each other. The time it takes to reset the counter,
for example, might depend on the previous count. Furthermore, the source itself
constantly changes in time as the number of remaining radioactive particles decreases
exponentially. Also, voltage drifts can introduce bias into the noise of electrical devices.
There are, of course, various tricks to overcome some of these disadvantages. One
can partially compensate for the counter-reset problem by replacing the string of bits
that represents a given count with a new number in which all of the original 1-1 and 0-0
pairs have been discarded and all of the original 0-1 and 1-0 pairs have been changed
to 0 and 1, respectively. This trick reduces the bias caused when the probability of a
0 is different from that of a 1 but does not completely eliminate nonindependence of
successive counts.
A shortcoming of any physical generator is the lack of reproducibility. Repro-
ducibility is needed for debugging codes that use the random numbers and for making
correlated or anti-correlated computations. Of course, if one wants random numbers
for a cryptographic one-time pad, reproducibility is the last attribute desired, and time
can be traded for security. A radioactive source used with the bias-removal technique
described above is probably sufficient.

Arithmetical Pseudo-Random Generators


The most common method of generating pseudo-random numbers on the computer
uses a recursive technique called the linear-congruential, or Lehmer, generator. The
sequence is defined on the set of integers by the recursion formula

xn+i = Axn + C (mod M ).

where xn is the nth member of the sequence, and A, C , and M are parameters that can
be adjusted for convenience and to ensure the pseudo-random nature of the sequence.
For example, M , the modulus, is frequently taken to be the word size on the computer,
and A, the multiplier, is chosen to yield both a long period for the sequence and good
statistical properties.
When M is a power of 2, it has been shown that a suitable sequence can be
generated if, among other things, C is odd and A satisfies A = 5 (mod 8) (that is, A - 5
is a multiple of 8). A simple example of the generation of a 5-bit number sequence
using these conditions would be to set M = 32 (5 bits), A = 21, C = 1, and xo = 13.
This yields the sequence

Los Alamos Science Special Issue 1987


Monte Carlo

Los Alamos Science Special Issue 1987 139


Monte Carlo

and

yield

Of course, if Seq. 3 is carried out to many places, a pattern in it will also become
apparent. To eliminate the new pattern, the sequence can be XOR'ed with a third
pseudo-random sequence of another type, and so on.
This type of hybrid sequence is easy to generate on a binary computer. Although
for most computations one does not have to go to such pains, the technique is especially
attractive for constructing "canonical" generators of apparently random numbers.
A key idea here is to take the notion of randomness to mean simply that the
sequence can pass a given set of statistical tests. In a sequence based on normal
numbers, each term will depend nonlinearly on the previous terms. As a result, there
are nonlinear statistical tests that can show the sequence not to be random. In particular,
a test based on the transformations used to construct the sequence itself will fail. But,
the sequence will pass all linear statistical tests, and, on that level, it can be considered
to be random.
What types of linear statistical tests are applied to pseudo-random numbers?
Traditionally, sequences are tested for uniformity of distribution of single elements,
pairs, triples, and so forth. Other tests may be performed depending on the type of
problem for which the sequence will be used. For example, just as the correlation
between two sequences can be tested, the auto-correlation of a single sequence can be
tested after displacing the original sequence by various amounts. Or the number of
different types of "runs" can be checked against the known statistics for runs. An
increasing run, for example, consists of a sequential string of increasing numbers
from the generator (such as, 0.08, 0.21, 0.55, 0.58, 0.73, . . .). The waiting times
for various events (such as the generation of a number in each of the five intervals
(0,0.2), (0.2,0.4), . . . , (0.8,l)) may be tallied and, again, checked against the known
statistics for random-number sequences.
If a generator of pseudo-random numbers passes these tests, it is deemed to be a
"good" generator, otherwise it is "bad." Calling these criteria "tests of randomness" is
misleading because one is testing a hypothesis known to be false. The usefulness of
the tests lies in their similarity to the problems that need to be solved using the stream
of pseudo-random numbers. If the generator fails one of the simple tests, it will surely
not perform reliably for the real problem. (Passing all such tests may not, however, be
enough to make a generator work for a given problem, but it makes the programmers
setting up the generator feel better.)

L o s Alamos Science Special Issue 1987


Monte Carlo

Los Alamos Science Special Issue 1987 141

You might also like