Table Of ContentUndergraduate Texts in Mathematics
Editorial Board
S. Axler
K.A. Ribet
For other titles published in this series, go to
http://www.springer.com/series/666
Ronald W. Shonkwiler
Franklin Mendivil
Explorations in
Monte Carlo Methods
Ronald W. Shonkwiler Franklin Mendivil
School of Mathematics Department of Mathematics and Statistics
Georgia Institute of Technology Acadia University
Atlanta, GA 30332-0160 Wolfville, NS B4P 2R6
USA Canada
shonkwiler@math.gatech.edu franklin.mendivil@acadiau.ca
Editorial Board
S. Axler K.A. Ribet
Mathematics Department Mathematics Department
San Francisco State University University of California at Berkeley
San Francisco, CA 94132 Berkeley, CA 94720-3840
USA USA
axler@sfsu.edu ribet@math.berkeley.edu
ISSN 0172-6056
ISBN978-0-387-87836-2 e-ISBN978-0-387-87837-9
DOI10.1007/978-0-387-87837-9
Springer Dordrecht Heidelberg London New York
Library of Congress Control Number: 2009932312
Mathematics Subject Classification (2000): 65C05 (primary), 68T05, 60J20 (secondary), 60G40 (tertiary)
©SpringerScience + BusinessMedia,LLC2009
Allrightsreserved. Thisworkmaynotbetranslatedorcopiedinwholeorinpartwithoutthewritten
permissionofthepublisher(SpringerScience+BusinessMedia,LLC,233SpringStreet,NewYork,NY
10013,USA),exceptforbriefexcerptsinconnectionwithreviewsorscholarlyanalysis.Useinconnection
withanyformofinformationstorageandretrieval,electronicadaptation,computersoftware,orbysimilar
ordissimilarmethodologynowknownorhereafterdevelopedisforbidden.
Theuseinthispublicationoftradenames,trademarks,servicemarks,andsimilarterms,eveniftheyare
notidentifiedassuch,isnottobetakenasanexpressionofopinionastowhetherornottheyaresubject
toproprietaryrights.
Printedonacid-freepaper
Springer is part of Springer Science+Business Media (www.springer.com)
Preface
The Monte Carlo method is a technique for analyzing phenomena by
means of computer algorithms that employ, in an essential way, the
generation of random numbers.
A solution by Monte Carlo methods was one of the very first uses
made of the newly invented digital computer. In a very real sense the
method was “born” with the computer. From the start, Monte Carlo
methods have been used to solve difficult problems for which no other
solutionmethodwasavailableatthetime.Thisisstillthecase.Insome
cases better methods arose and displaced Monte Carlo; as it should be.
Yet, in many applications Monte Carlo is unsurpassed. It still enjoys
almostexclusivedominionoveritsoriginalapplication,simulatingcom-
plex interactions in any area where quantitative models are possible.
In the meantime Monte Carlo has moved ahead as well, finding new
areas of application and enjoying new resurgence in former areas as a
result of increased computer power. Today Monte Carlo methods are
more widespread than ever.
Monte Carlo methods originated in their modern form with, and
were named by, Stanislaw Ulam and John von Neumann. Later Ulam
went on to expand on the method and champion its use. He inspired
many subsequent adherent’s who themselves developed and extended
the method. To “Stan,” as he was known to his friends, Monte Carlo
was just one technique for performing mathematical experiments on
the computer, an idea in which he fervently believed.
In this book we show how Monte Carlo can be used to solve prob-
lems in science, engineering, business, and industry. But most of all,
we intend to have fun. We will use the computer to explore the hidden
and sometimes surprising nature of quantitative systems. From throw-
vi Preface
ing needles on cracks to playing blackjack, from following sea birds
searching for food to using computer creatures to solve optimization
problems, we will explore what Monte Carlo can do.
Along theway wewill learn and improve skills in probability, statis-
tics, programming, mathematics, and even Monte Carlo methods. For
example, the central limit theorem plays a central role in many parts
of the book. And we will learn that computer random numbers are not
randomatall; nevertheless,asourceof good“pseudorandom”numbers
is essential to the method.
The initial mathematical skills the student should have are calculus
throughintegrationandmatrixarithmetic.Afamiliaritywithprogram-
ming is helpful, but the programming in this text starts at an elemen-
tarylevelandproceedsgraduallyinscope.A“computerinclined”mind
is probably more important. Our demonstration programs are amply
commented.
ProgrammingisattheheartofMonteCarlomethodsandwillbethe
primaryactivity of ourwork inthis text. Allthatwelearn anddiscover
emerges in the display of the results of our programs. Toward that end
weprovidealargenumberofproblemsforcomputersolutionattheend
ofeach chapter.Thestatement ofeach problemisprefixedbyanumber
in parentheses indicating the relative difficulty or time requirement for
that problem. These are only estimates, however; your perception may
bedifferent,buthopefullynotbytoomuch.Keepinmindthatcreating
anddebuggingcodealwaystakesmoretimethanexpected.Hofstadter’s
Law states: it always takes longer than you expect, even when you take
Hofstadter’s Law into account.
With regard to programming, quick, short, and simple solutions is
a major feature of Monte Carlo methods. For example the program on
page 4 for simulating the Buffon needle problem mentioned above is
just seven lines. Generally, programs in the earlier chapters tend to be
small and simple. Later on, they become a little more elaborate. Thus
the program for pricing options via simulation on page 178 is a bit
longer at 24 lines.
Besides the numerical computations, the results have to be graph-
ically displayed. Most convenient is a software package that can do
both. We have chosen to use Matlab for illustration purposes through-
out. Rather than using pseudocode for this purpose, Matlab is itself
easy to understand, and the code presented can be directly run within
Matlab. The included code produced many of the figures in the text.
However, while Matlab is good as a mathematics and graphics pack-
Preface vii
age, it is not optimal as a programming language. We recommend that
for the serious implementation of a Monte Carlo solution, for example
in optimization, a richer programming language be used such as C or
Java.
As a note to any instructor using this book, we have found over the
years in teaching a course based on this material that an excellent way
to finish up is having students do a final project of their own choosing;
see Appendix C. Be prepared for some very impressive submissions.
Atlanta, Georgia Ronald Shonkwiler
Wolfville, Nova Scotia Franklin Mendivil
viii Preface
Acknowledgments
One of us (Shonkwiler) had the great fortune of having gotten to know
Stan Ulam, in part through a set theory course he taught at the Uni-
versity of Colorado. As anyone whose life he touched will testify, he
was a most enthusiastic, inspiring, genuinely creative, and yet humble
person.
Wewishtothank David Kramerfor hisoutstandingjob copyediting
theoriginalmanuscript,LauraHeldforhercheerfulmanagementofthe
work from its infancy to completion, and Ann Kostant for her initial
inspiration and for looking in from time to time keeping us on track.
Finally, we give a special thanks to our students, who show an abiding
interest in the material, ask insightful questions, and sometimes find
novelsolutionstotheproblems.Ultimately itisforthemthatoureffort
is sustained.
Contents
Preface .................................................. v
1 Introduction to Monte Carlo Methods ............... 1
1.1 How Can Random Numbers Solve Problems? .......... 1
1.1.1 History of the Monte Carlo Method ............. 2
1.1.2 Histogramming Simulation Results.............. 4
1.1.3 Sample Paths ................................ 8
1.2 Some Basic Probability ............................. 10
1.2.1 Events and Random Variables.................. 10
1.2.2 Discrete and Continuous Random Variables ...... 11
1.2.3 The Probability Density Function............... 14
1.2.4 Expected Values.............................. 16
1.2.5 Conditional Probabilities ...................... 20
1.2.6 Variance for a Sum of Random Variables–
Joint Probability Densities..................... 24
1.3 Random Number Generation ........................ 28
1.3.1 Requirements for a Random Number Generator
(RNG) ...................................... 28
1.3.2 Middle-Square and Other Middle-Digit Techniques 31
1.3.3 Linear Congruential Random Number Generators. 32
1.4 Some Applications ................................. 37
Problems: Chapter 1.................................... 43
2 Some Probability Distributions and Their Uses ...... 51
2.1 CDF Inversion–Discrete Case: Bernoulli Trials ......... 51
2.1.1 Two-Outcome CDF Inversion .................. 52
2.1.2 Multiple-Outcome Distributions ................ 53
Description:Monte Carlo methods are among the most used and useful computational tools available today, providing efficient and practical algorithims to solve a wide range of scientific and engineering problems. Applications covered in this book include optimization, finance, statistical mechanics, birth and de