Вы находитесь на странице: 1из 13

Intro

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

ate a free throw.

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
#MACRO? ### ###
draw

### ###

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
1 #MACRO? The exact same formula is used in the 100 cells from B4 to B
2 #MACRO? Hit F9 to simulate another 100 free throws.
3 #MACRO? How did Larry do this time?
4 #MACRO?
5 #MACRO? Hit F9 again and again. Watch cell B1.
6 #MACRO? How much spread or bounce is there?
7 #MACRO?
8 #MACRO? Wouldn't it make sense to keep track of Larry's sample percentage?
9 #MACRO? Click on the button below to do so.
10 #MACRO?
11 #MACRO?
12 #MACRO?
13 #MACRO? Curious about streaks? Click on the button below.
14 #MACRO? Click this button several times.
15 #MACRO?
16 #MACRO?
17 #MACRO? Do you think Max Streaks follow a normal distribution?
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

aws (free throw attempts).

mula in Cell B4 informs Excel of this chance process.


the 100 cells from B4 to B103. Click on a few of these cells to see for yourself.

sample percentage?

simulation that answers this question.

Page 10
Q&A for MonteCarlo.xls
1) Run a Monte Carlo with 1,000 repetitions of the percentage made of 100 free throws.
Use the Take a Picture button to take a picture of your results.
Copy and paste the picture in a Word document.

2) Run a Monte Carlo with 10,000 repetitions of the percentage made of 100 free throws.
Take a picture, copy it, and paste it in the Word document below the 1,000 repetition Monte Carlo.

3) In what sense is the 10,000 repetition Monte Carlo better than the 1,000 repetition Monte Carlo in this example?

4) Run a Max Streak Monte Carlo.


Take a picture, copy it, and paste it in the Word document.

5) What are the chances that the virtual Larry Bird gets a max streak of 51 in a row or more?
Explain how you arrived at your answer.
n Monte Carlo.

rlo in this example?


Monte Carlo Simulation of Sample Percentage with 10000 Repetitions
Max
Sample Sample
Number Streak
1 15
2 22 Time Elapsed 2.00 secs
3 32
4 16 3000 Empirical Histogram for 10000 Repetitions
5 21 Summary Statistics
2500
6 43 Average = 27.0
7 17 2000
8 16 SD = 9.7
9 22 1500 Max = 89
10 27
Min = 8
11 38 1000
12 28
13 36 500
14 36
15 29 0
0 to 6 to 11 16 21 26 31 36 41 46 51 56 61 66 71 76 81 86 91 96
16 21 5 10 to to to to to to to to to to to to to to to to to to
15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100
17 25
18 14
19 16

Вам также может понравиться