monte carlo overview

44
Intro Page 1 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. We can repeat this process, again and again, keeping track of the result each t at the empirical histogram and summary statistics of the results in order to di statistical properties of the chance process. This method of studying a chance Monte Carlo simulation. There are other hidden sheet in this workbook. The OneFreeThrow sheet shows how Excel can be used draw a random number and simul The Sample sheet has the outcome of 100 free throw attempts.

Upload: ujang01

Post on 12-Dec-2015

33 views

Category:

Documents


3 download

DESCRIPTION

Monte Carlo simulation

TRANSCRIPT

Page 1: Monte Carlo Overview

Intro

Page 1

Intro to MonteCarlo.xlsThis 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.

There are other hidden sheet in this workbook.

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.

Page 2: Monte Carlo Overview

Intro

Page 2

sheet shows how Excel can be used draw a random number and simulate a free throw.

Page 3: Monte Carlo Overview

OneFreeThrow

Page 3

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 sections 9.2 and 9.3.

#MACRO?

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.

#MACRO? ### ###

### ###

Combining the RAND and IF statements into a single formula, we get a virtual 90% free throw shooter:

#MACRO?

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:

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 wheneverthe user enters new information anywhere in the workbook OR it can be in Manual Calculatemode, 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 notautomatically recalculated the cells in the workbook. If you hit F9, the "Calculate" message

Random draw

Random draw

Larry Bird Simulated

Excel is drawing different random numbers in cells B18 and B23. Every time it sees

Page 4: Monte Carlo Overview

OneFreeThrow

Page 4

will disappear. Section 9.3 explains about Calculation in more detail and shows how to set the calculation mode.

Page 5: Monte Carlo Overview

OneFreeThrow

Page 5

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 sections 9.2 and 9.3.

Page 6: Monte Carlo Overview

OneFreeThrow

Page 6

will disappear. Section 9.3 explains about Calculation in more detail and shows how to set the calculation mode.

Page 7: Monte Carlo Overview

Sample

Page 7

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 Excel of this chance process.

1 #MACRO? The exact same formula is used in the 100 cells from B4 to B103. Click on a few of these cells to see for yourself.

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 this question.

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?

Page 8: Monte Carlo Overview

Sample

Page 8

38 #MACRO?

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?

Page 9: Monte Carlo Overview

Sample

Page 9

78 #MACRO?

79 #MACRO?

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 10: Monte Carlo Overview

Sample

Page 10

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 Excel of this chance process.

The exact same formula is used in the 100 cells from B4 to B103. Click on a few of these cells to see for yourself.

Wouldn't it make sense to keep track of Larry's sample percentage?

Click on the button below to see a Monte Carlo simulation that answers this question.

Page 11: Monte Carlo Overview

Q&A for MonteCarlo.xls1) 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.

Page 12: Monte Carlo Overview

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?

Page 13: Monte Carlo Overview

Monte Carlo Simulation of Sample Percentage with 1000 Repetitions

1 95%2 93% Time Elapsed 2 secs3 92%4 89%5 93%6 93%7 84%8 89%9 92%

10 84%11 91%12 89%13 87%14 88%15 94%16 89%17 96%18 89%19 88%20 94%21 92%22 90%23 90%24 93%25 87%26 93%27 92%28 90%29 87%30 86%31 86%32 90%33 92%34 91%35 92%

Sample Number

Sample Percentage

Excel Tip: Pause the cursor over one of the bars, the number of samples (or height of the bar) is displayed.

78%

80%

82%

84%

86%

88%

90%

92%

94%

96%

98%

100%

0

20

40

60

80

100

120

140Empirical Histogram for 1000 Repetitions

Min = 80%

Average = 89.91%SD = 3.012%

Summary Statistics

Max = 97%

Page 14: Monte Carlo Overview

36 90%37 86%38 89%39 89%40 97%41 88%42 92%43 94%44 93%45 87%46 91%47 90%48 94%49 92%50 92%51 92%52 91%53 90%54 91%55 91%56 94%57 87%58 84%59 89%60 91%61 90%62 88%63 91%64 91%65 88%66 92%67 84%68 89%69 94%70 91%71 93%72 90%73 89%74 90%75 91%76 91%

Page 15: Monte Carlo Overview

77 89%78 91%79 89%80 94%81 93%82 91%83 96%84 88%85 92%86 90%87 89%88 88%89 84%90 92%91 85%92 88%93 91%94 93%95 93%96 91%97 87%98 94%99 88%

100 89%101 91%102 91%103 91%104 83%105 88%106 90%107 88%108 93%109 84%110 86%111 89%112 88%113 86%114 89%115 92%116 93%117 90%

Page 16: Monte Carlo Overview

118 87%119 87%120 86%121 90%122 93%123 91%124 91%125 91%126 91%127 90%128 92%129 92%130 96%131 93%132 89%133 86%134 89%135 87%136 88%137 90%138 89%139 87%140 87%141 90%142 89%143 90%144 91%145 89%146 96%147 91%148 82%149 88%150 92%151 87%152 97%153 89%154 94%155 87%156 95%157 93%158 89%

Page 17: Monte Carlo Overview

159 88%160 93%161 88%162 86%163 93%164 92%165 89%166 89%167 90%168 96%169 90%170 88%171 90%172 89%173 88%174 93%175 89%176 91%177 94%178 87%179 93%180 94%181 93%182 90%183 84%184 90%185 92%186 91%187 89%188 93%189 87%190 92%191 92%192 93%193 89%194 96%195 89%196 90%197 87%198 94%199 90%

Page 18: Monte Carlo Overview

200 91%201 92%202 84%203 95%204 84%205 88%206 93%207 89%208 87%209 93%210 95%211 88%212 82%213 85%214 89%215 91%216 92%217 94%218 93%219 87%220 87%221 93%222 90%223 94%224 82%225 85%226 87%227 91%228 89%229 89%230 90%231 88%232 92%233 90%234 90%235 89%236 88%237 87%238 92%239 96%240 86%

Page 19: Monte Carlo Overview

241 90%242 89%243 91%244 91%245 88%246 88%247 88%248 91%249 89%250 91%251 93%252 86%253 90%254 90%255 88%256 88%257 89%258 91%259 90%260 88%261 88%262 94%263 95%264 90%265 91%266 90%267 91%268 88%269 88%270 92%271 86%272 94%273 83%274 89%275 94%276 91%277 91%278 89%279 91%280 93%281 93%

Page 20: Monte Carlo Overview

282 90%283 84%284 89%285 90%286 90%287 93%288 91%289 86%290 88%291 91%292 87%293 90%294 90%295 90%296 92%297 88%298 88%299 86%300 91%301 86%302 88%303 89%304 91%305 86%306 87%307 89%308 91%309 86%310 93%311 92%312 88%313 92%314 89%315 90%316 87%317 89%318 92%319 87%320 89%321 91%322 88%

Page 21: Monte Carlo Overview

323 86%324 86%325 87%326 87%327 92%328 89%329 97%330 88%331 88%332 86%333 91%334 90%335 84%336 93%337 87%338 94%339 92%340 88%341 90%342 90%343 90%344 95%345 90%346 90%347 91%348 93%349 88%350 85%351 86%352 89%353 91%354 93%355 86%356 90%357 94%358 92%359 88%360 90%361 91%362 92%363 91%

Page 22: Monte Carlo Overview

364 95%365 92%366 94%367 90%368 88%369 89%370 94%371 88%372 86%373 90%374 85%375 94%376 90%377 92%378 90%379 90%380 86%381 92%382 86%383 96%384 95%385 88%386 90%387 90%388 89%389 91%390 87%391 88%392 89%393 92%394 84%395 94%396 85%397 92%398 89%399 92%400 93%401 88%402 87%403 92%404 95%

Page 23: Monte Carlo Overview

405 89%406 91%407 90%408 92%409 88%410 93%411 94%412 88%413 84%414 90%415 86%416 91%417 82%418 93%419 88%420 93%421 92%422 88%423 91%424 88%425 94%426 86%427 88%428 85%429 90%430 92%431 88%432 89%433 91%434 89%435 92%436 91%437 90%438 91%439 89%440 86%441 91%442 91%443 91%444 89%445 87%

Page 24: Monte Carlo Overview

446 88%447 91%448 91%449 94%450 93%451 91%452 87%453 89%454 93%455 91%456 96%457 95%458 85%459 87%460 93%461 93%462 89%463 93%464 87%465 94%466 85%467 94%468 89%469 90%470 93%471 91%472 84%473 93%474 93%475 92%476 89%477 93%478 89%479 85%480 90%481 88%482 95%483 91%484 82%485 91%486 89%

Page 25: Monte Carlo Overview

487 90%488 84%489 93%490 95%491 93%492 89%493 91%494 93%495 85%496 92%497 95%498 84%499 89%500 93%501 82%502 88%503 92%504 84%505 89%506 95%507 87%508 92%509 90%510 86%511 93%512 86%513 93%514 90%515 88%516 87%517 88%518 85%519 92%520 90%521 89%522 92%523 94%524 88%525 90%526 89%527 95%

Page 26: Monte Carlo Overview

528 93%529 93%530 92%531 91%532 93%533 92%534 92%535 85%536 92%537 84%538 91%539 89%540 94%541 89%542 84%543 91%544 91%545 92%546 92%547 91%548 90%549 90%550 94%551 86%552 90%553 89%554 90%555 88%556 91%557 92%558 91%559 92%560 91%561 92%562 94%563 86%564 89%565 92%566 87%567 88%568 91%

Page 27: Monte Carlo Overview

569 87%570 89%571 93%572 90%573 90%574 89%575 91%576 85%577 90%578 91%579 89%580 89%581 85%582 85%583 88%584 87%585 91%586 88%587 85%588 90%589 85%590 94%591 91%592 93%593 91%594 92%595 89%596 90%597 90%598 89%599 86%600 84%601 86%602 92%603 87%604 93%605 91%606 92%607 91%608 83%609 85%

Page 28: Monte Carlo Overview

610 89%611 93%612 85%613 93%614 90%615 91%616 87%617 89%618 89%619 88%620 93%621 92%622 87%623 92%624 92%625 94%626 86%627 97%628 89%629 93%630 91%631 92%632 88%633 91%634 88%635 91%636 88%637 85%638 88%639 89%640 86%641 90%642 90%643 94%644 87%645 90%646 87%647 97%648 87%649 91%650 84%

Page 29: Monte Carlo Overview

651 93%652 91%653 90%654 91%655 91%656 93%657 85%658 93%659 93%660 83%661 81%662 94%663 88%664 89%665 94%666 91%667 88%668 89%669 93%670 90%671 92%672 90%673 84%674 87%675 90%676 85%677 87%678 95%679 95%680 93%681 84%682 92%683 93%684 96%685 90%686 89%687 87%688 85%689 86%690 90%691 91%

Page 30: Monte Carlo Overview

692 84%693 88%694 90%695 89%696 87%697 89%698 88%699 87%700 80%701 90%702 92%703 97%704 82%705 90%706 95%707 91%708 91%709 90%710 88%711 94%712 93%713 88%714 88%715 86%716 93%717 90%718 92%719 92%720 85%721 94%722 91%723 93%724 88%725 91%726 90%727 94%728 90%729 88%730 86%731 91%732 92%

Page 31: Monte Carlo Overview

733 95%734 90%735 96%736 91%737 90%738 89%739 94%740 92%741 93%742 85%743 95%744 90%745 89%746 92%747 86%748 92%749 91%750 87%751 87%752 88%753 88%754 95%755 91%756 90%757 93%758 91%759 93%760 91%761 88%762 94%763 89%764 88%765 94%766 85%767 90%768 93%769 85%770 85%771 94%772 94%773 88%

Page 32: Monte Carlo Overview

774 89%775 90%776 94%777 91%778 89%779 89%780 90%781 88%782 88%783 84%784 88%785 89%786 92%787 89%788 88%789 88%790 89%791 90%792 83%793 95%794 90%795 89%796 94%797 89%798 85%799 89%800 94%801 92%802 89%803 90%804 92%805 94%806 89%807 91%808 89%809 88%810 87%811 90%812 95%813 90%814 88%

Page 33: Monte Carlo Overview

815 94%816 93%817 88%818 92%819 90%820 88%821 91%822 92%823 93%824 93%825 84%826 92%827 94%828 89%829 90%830 86%831 88%832 86%833 84%834 85%835 83%836 85%837 85%838 87%839 89%840 89%841 92%842 89%843 91%844 86%845 90%846 94%847 88%848 91%849 91%850 87%851 83%852 92%853 90%854 96%855 92%

Page 34: Monte Carlo Overview

856 89%857 94%858 95%859 92%860 94%861 88%862 89%863 85%864 87%865 95%866 89%867 89%868 93%869 86%870 89%871 87%872 88%873 88%874 92%875 90%876 93%877 90%878 93%879 86%880 92%881 87%882 89%883 89%884 88%885 91%886 94%887 93%888 92%889 90%890 94%891 90%892 90%893 81%894 93%895 92%896 91%

Page 35: Monte Carlo Overview

897 92%898 91%899 93%900 94%901 93%902 92%903 87%904 87%905 89%906 80%907 87%908 92%909 88%910 95%911 89%912 88%913 88%914 92%915 90%916 86%917 89%918 88%919 91%920 86%921 92%922 85%923 93%924 90%925 88%926 86%927 89%928 92%929 88%930 94%931 86%932 94%933 90%934 90%935 88%936 94%937 91%

Page 36: Monte Carlo Overview

938 96%939 90%940 92%941 89%942 90%943 91%944 93%945 92%946 91%947 87%948 91%949 84%950 89%951 85%952 96%953 91%954 91%955 92%956 90%957 95%958 96%959 88%960 94%961 88%962 91%963 94%964 89%965 89%966 89%967 89%968 94%969 91%970 92%971 91%972 93%973 89%974 89%975 84%976 91%977 90%978 91%

Page 37: Monte Carlo Overview

979 94%980 87%981 89%982 81%983 92%984 95%985 85%986 88%987 92%988 88%989 91%990 91%991 93%992 91%993 94%994 91%995 89%996 88%997 93%998 94%999 88%

1000 91%

Page 38: Monte Carlo Overview

Monte Carlo Simulation of Sample Percentage with 1000 Repetitions Min = 80%

Max = 97%Average = 89.91%SD = 3.012%

Excel Tip: Pause the cursor over one of the bars, the number of samples (or height of the bar) is displayed.

78%

80%

82%

84%

86%

88%

90%

92%

94%

96%

98%

100%

0

20

40

60

80

100

120

140Empirical Histogram for 1000 Repetitions

Min = 80%

Average = 89.91%SD = 3.012%

Summary Statistics

Max = 97%

Page 39: Monte Carlo Overview

Min = 80%

Max = 97%Average = 89.91%SD = 3.012%

Page 40: Monte Carlo Overview

Bin Value78% 079% 080% 281% 382% 783% 784% 2985% 3786% 4887% 6388% 11189% 12890% 12491% 13192% 10393% 9294% 6695% 2896% 1597% 698% 099% 0

100% 0

Number of

Samples

Page 41: Monte Carlo Overview

Monte Carlo Simulation of Sample Percentage with 1000 Repetitions

1 192 30 Time Elapsed 1.00 secs3 434 145 156 337 318 259 25

10 3011 1712 1813 1714 2215 2016 3017 2818 2119 19

Sample Number

Max Sample Streak

0 to 5

6 to 10

11 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 to 95

96 to

100

0

50

100

150

200

250

300Empirical Histogram for 1000 Repetitions

Min = 10

Average = 27.0

SD = 9.3

Summary Statistics

Max = 67