You are on page 1of 10

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 s Random draw 0.822815617463931

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 0.012194132438020 Make Make 1 1

Combining the RAND and IF statements into a single formula, we get a virtual 90% free throw shooter: Larry Bird 1 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 will disappear. Section 9.3 explains about Calculation in more detail and shows how to set the calculation mode.

Page 3

OneFreeThrow

ndom number generation, see sections 9.2 and 9.3.

alculation mode.

Page 4

Sample

Percentage Made Attempt 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39

90% Result 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 0 1

This sheet contains a single repetition of 100 draws (free throw attempts)

Larry Bird hits 90% of his free throws. The formula in Cell B4 informs Exc Hit F9 to simulate another 100 free throws. How did Larry do this time? Hit F9 again and again. Watch cell B1. How much spread or bounce is there? Wouldn't it make sense to keep track of Larry's sample percentage? Click on the button below to do so.

The exact same formula is used in the 100 cells from B4 to B

Curious about streaks? Click on the button below. Click this button several times.

Do you think Max Streaks follow a normal distribution?

Click on the button below to see a Monte Carlo simulation that answers th

Page 5

Sample
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 0

Page 6

Sample
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1

Page 7

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 8

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.

o in this example?

You might also like