Professional Documents
Culture Documents
Intro To Montecarlo
Intro To Montecarlo
Intro to MonteCarlo.xls
This workbook introduces Monte Carlo Simulation with a simple example.
In this book, we use Microsoft Excel to simulate chance processes.
Typically, we use Excel to draw a sample, then compute a sample statistic, e.g., the sample average.
We can repeat this process, again and again, keeping track of the result each time. We then look
at the empirical histogram and summary statistics of the results in order to discover or illustrate the
statistical properties of the chance process. This method of studying a chance process is called
Monte Carlo simulation.
The OneFreeThrow sheet shows how Excel can be used draw a random number and simulate a free throw.
The Sample sheet has the outcome of 100 free throw attempts.
There are other hidden sheet in this workbook.
Page 1
Intro
Page 2
OneFreeThrow
To simulate a free throw, we use a random draw in an IF statement. Scroll down to see how.
The random draw uses the formula, "=RANDOM()", to get a uniformly distributed number in the 0,1 interval.
Click in cell B5 to see the formula. Hit F9 (or CTRL - =) to draw a new number. For more on random number generation, see
Random
#MACRO?
draw
The RANDOM() function is the foundation of the Monte Carlo Simulation because it's our roulette wheel,
but we need one more concept to complete the simulation. We need a way to tell Excel that Larry
has a 90% chance of making the free throw.
Fortunately, this is easily done with an IF statement.
Take a look at the formulas in cells B18, D18, and D18.
Cell D18 says, "if the value in cell B18 is less than 0.9, then the value of this cell is 1, else the value is 0."
The structure is "expression to be evaluated," "value if true," "value if false."
Notice the difference between cells D18 and D19--yet they end up doing the same thing.
While you are at it, try to figure out what's going on in cells C18 and C19.
Random
draw
#MACRO?
###
###
###
###
Combining the RAND and IF statements into a single formula, we get a virtual 90% free throw shooter:
Larry Bird
#MACRO?
Simulated
Notice that this outcome will occasionally differ from the one above. The reason is that
it's based on a different draw from the uniform distribution.
Hit F9 (or CTRL - =) repeatedly (say 30 times in a row) to see how Larry's doing.
As long as the value stays at 1, Larry hit the free throw. When it changes to 0, he missed.
Question:
"I noticed that sometimes he misses in cell B23, but makes it in cells C18 through D19. What's going on?"
Answer:
Excel is drawing different random numbers in cells B18 and B23. Every time it sees
RANDOM() in a cell, Excel draws a new random number.
Question:
"Sometimes I see the word "Calculate" at the bottom of the screen. What does that mean?"
Answer:
Excel can be set up to automatically calculate the values of every formula whenever
the user enters new information anywhere in the workbook OR it can be in Manual Calculate
mode, which means that it will not automatically recalculate. Manual Calculation is needed for
Monte Carlo simulation to prevent constant redrawing of random numbers. The "Calculate"
message in the Status Bar at the bottom of the screen alerts the reader that Excel has not
automatically recalculated the cells in the workbook. If you hit F9, the "Calculate" message
Page 3
OneFreeThrow
will disappear. Section 9.3 explains about Calculation in more detail and shows how to set the calculation mode.
Page 4
OneFreeThrow
0,1 interval.
ndom number generation, see sections 9.2 and 9.3.
Page 5
OneFreeThrow
calculation mode.
Page 6
Sample
Percentage Made
#MACRO?
This sheet contains a single repetition of 100 draws (free throw attempts)
Attempt
Result
Larry Bird hits 90% of his free throws. The formula in Cell B4 informs Exc
#MACRO?
#MACRO?
#MACRO?
#MACRO?
#MACRO?
#MACRO?
#MACRO?
#MACRO?
#MACRO?
10
#MACRO?
11
#MACRO?
12
#MACRO?
13
#MACRO?
14
#MACRO?
15
#MACRO?
16
#MACRO?
17
#MACRO?
18
#MACRO?
Click on the button below to see a Monte Carlo simulation that answers th
19
#MACRO?
20
#MACRO?
21
#MACRO?
22
#MACRO?
23
#MACRO?
24
#MACRO?
25
#MACRO?
26
#MACRO?
27
#MACRO?
28
#MACRO?
29
#MACRO?
30
#MACRO?
31
#MACRO?
32
#MACRO?
33
#MACRO?
34
#MACRO?
35
#MACRO?
36
#MACRO?
37
#MACRO?
38
#MACRO?
Page 7
Sample
39
#MACRO?
40
#MACRO?
41
#MACRO?
42
#MACRO?
43
#MACRO?
44
#MACRO?
45
#MACRO?
46
#MACRO?
47
#MACRO?
48
#MACRO?
49
#MACRO?
50
#MACRO?
51
#MACRO?
52
#MACRO?
53
#MACRO?
54
#MACRO?
55
#MACRO?
56
#MACRO?
57
#MACRO?
58
#MACRO?
59
#MACRO?
60
#MACRO?
61
#MACRO?
62
#MACRO?
63
#MACRO?
64
#MACRO?
65
#MACRO?
66
#MACRO?
67
#MACRO?
68
#MACRO?
69
#MACRO?
70
#MACRO?
71
#MACRO?
72
#MACRO?
73
#MACRO?
74
#MACRO?
75
#MACRO?
76
#MACRO?
77
#MACRO?
78
#MACRO?
79
#MACRO?
Page 8
Sample
80
#MACRO?
81
#MACRO?
82
#MACRO?
83
#MACRO?
84
#MACRO?
85
#MACRO?
86
#MACRO?
87
#MACRO?
88
#MACRO?
89
#MACRO?
90
#MACRO?
91
#MACRO?
92
#MACRO?
93
#MACRO?
94
#MACRO?
95
#MACRO?
96
#MACRO?
97
#MACRO?
98
#MACRO?
99
#MACRO?
100
#MACRO?
Page 9
Sample
sample percentage?
Page 10
Sample
Page 11
Sample
Page 12
n Monte Carlo.
Max
Sample
Streak
15
22
32
16
21
43
17
16
22
27
38
28
36
36
29
21
25
14
16
Time Elapsed
2.00 secs
Empirical Histogram for 10000 Repetitions
3000
Summary Statistics
2500
Average = 27.0
2000
SD = 9.7
Max = 89
1500
Min = 8
1000
500
0
0 to 6 to 11
5
10 to
15
16
to
20
21
to
25
26
to
30
31
to
35
36
to
40
41
to
45
46
to
50
51
to
55
56
to
60
61
to
65
66
to
70
71
to
75
76
to
80
81
to
85
86
to
90
91 96
to to
95 100