Professional Documents
Culture Documents
Excelvbaplication 2010
Excelvbaplication 2010
10
M. Auer, 2004-2012
Distributed under terms of GNU General Public License
www.montecarlito.com
This tutorial explains how MonteCarlito can be used to run Monte Carlo
simulations in Excel.
Example 1: Basics
To answer that question, you determine the expected profit/loss; an easy way
to do this is to simulate the game many times and average the individual outcomes.
To simulate this in Excel, first you need to create a random number from 0-1 with RAND():
Random number: 0.971462354 (press F9 several times to see how this number ch
To play the game once, determine the profit of the dice throw, and subtract the costs:
Game profit: 36
Costs: 14
Pressing F9 repeatedly reveals that sometimes you win, sometimes you lose money.
If you repeat this many times and analyze the outcomes, you can determine if you should play.
Now, select the whole light blue area (2x2 cells) and press Ctrl+W.
MonteCarlito runs the simulation 1000 times, and gives you the average result. If it's positive, you should pl
0-1 with RAND():
ose money.
ine if you should play.
You could throw a dart at a 4cm x 4cm sized rectangle with a circle painted on it,
repeat this 1000 times, and count the number of throws landing in the circle area (call it C) and
the number of throws landing on the rectangle, in- or outside the circle (call this number R).
The ratio of C/R should be fairly similar to the ratio of the circle area and the rectangle area (which is 4 x 4 = 16)
Thus PI = 4 x C/R
To simulate one dart throw, first create two random numbers (the x and y coordinate) between -2 and 2:
x y
Throw to coordinates: 1.175614091 -0.75917264 (press F9 a few times to make sure tha
press F9 a few times to make sure that the throw is between -2 and 2 in both axes)
MonteCarlito can not only answer the expected total effort, but
also its distribution, and thus answer questions like "what are the 10% of outcomes that are worst?"
A very similar issue arises when computing financial measure like the value-at-risk (VAR).
This means roughly that in 95% of all outcomes, the effort is between 47.95866648
and 47.95866648
es that are worst?"
plus 19.95359431
minus 19.95359431
MonteCarlito
Instructions:
1. Put all N formulas you want to simulate next to each other, preceded by the number of trials you want to run.
2. Select the N+1 cells and the 7x(N+1) cells beneath (indicated by frame).
Note:
- If the number of trials is negative, simulation is run in high-speed mode with minimized windows.
- If the cell with the number of trials has bold font type, histograms are created at end of simulation run.
- If you select less than 7 rows of cells beneath formulas, you get less output.
Examples:
b) Select range I18:J21; press Ctrl+W (a new workbook will be created with histogram).
1000 -1.2115223022
h histogram).