This preview shows pages 1–8. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: Simple Monte Carlo Simulation using Excel and
Links among Simulation, Statistics and Probability 1. Decision Making under Uncertainty Simulation is typically used to help make decisions in the presence of uncertainty. One might
very well ask whether we need to go through the trouble of performing a simulation. Perhaps
we can just plug in the expected values of the random variables that inﬂuence our decision and make a. decision without the need for simulation. The following example illustrates why simply plugging the expected values of the random
variables may not be a good idea. You are playing a game where you pick two people from a
large population at random and compute the ratio between the ages of the ﬁrst and second
person. Your pay off is equal to the ratio between the ages of the two people. Assume that
the age of a random person from the population is uniformly distributed over [1, 80]. What is your expected payoff? A tempting answer is to argue that the expectation of the age of each person is 40%.
Therefore, the expectation of the ratio between the ages is 1. It turns out this answer is not quite right. To see this, let X and Y respectively be the ages of the ﬁrst and second person. Since
the population is large, it is reasonable to assume that X and Y are independent random
variables and they are both uniformly distributed over [1,80]. We are interested in computing
1E{X / Y}. We build a spreadsheet that looks like the following. A B C
First Age Second Age Payoff 1
=1+79*RAND O =1+79*RAND O =A2/B2 The spreadsheet above simulates the draw of two people from the population. Each time we
run the simulation model, we plug different values for the ages of the two people and observe the payoff, which is the ratio between the two ages. If we do this many, say 1,000,000, times,
then we can obtain a histogram for the payoff. This histogram looks like the following. 300.000
250.000
200,000 150,000 ‘ Frequency 100,000 50,000 14 From the histogram, we observe that the expected payoff is signiﬁcantly larger than 1. To see what happened, let the function g(z,y) be deﬁned as g(:r,y) = In this case,
the expected payoff is given by lE{X/Y} = IE{g(X, On the other hand, the argument that provided the expected payoff of 1 computes ]E{X} = g(lE{X If we had g(lE{X},lE{Y}) = lE{g(X,Y)}, then the expected payoff would have been
lE‘.{X/Y} = lE{g(X,Y)} = g(]E{X},lE{Y}) = = 1. However, except for very
special cases, we almost never have ]E{g(X, Y)} : g(lE{X}, The moral of the example
is Average “Fain {Lg m'l X/lflel OVPIOQQ DU‘f'ruii This is perhaps the most important reason for using simulation. Note also that by performing a simulation we discovered something about the spread of the payoff. Therefore, simulation added to our insight about the behavior of the problem.
This is the second reason for using simulation. Finally, we could run simulations for different types of games and we choose a game to play. That is, we could have used simulation to
evaluate alternative system designs and choose the best one. This is a third reason for using simulation. 2. Making Expectation and Probability Computations by Using Simulation " ' M On the game show “Who Wants to be a Bazillionaire?” contestants win fabulous
prizes for answering stupid questions. If the contestant gets the answer correct, then the
winnings W are obtained by multiplying the prize (P) with the bonus multiplier That 15,
W = BP. The prize P is random and uniformly distributed over the interval [$1000, $3000]. The bonus
multiplier B has a discrete uniform distribution over the interval [1,20], so that it can take on the values {1, 2, . . . ,20} with equal probability. Question * What is the expected winnings? What is the probability that the winnings will
be at least $20000? Method 1 7 Try to compute analytically. l—lrrii ire‘5‘ 0“ Method 2 — Experiment by playing the game 100 times. Compute the average winnings to
estimate the expectation. Use the proportion of games on which the even ” occurred to estimate the probability. ’1’ng «3 ﬂ, [5 L 3.; law. Q
Method 3 * Use the power of computer to experiment — do a simulation study! Generating the required random numbers * To make this work, we need a way of
getting the computer to mimic the play of the game. Every computer has a uniform random 15 number generator that generates uniformly distributed random variables over the interval
[0,1]. So, how do we “transform” this uniform randomness over the interval [0,1] into the distributions that we need? Using the function =RANDO in Excel, we can generate a uniformly distributed random
variable U over the interval [0,1]. Question — How can we transform the random variable U into the prize random variable P,
which is uniformly distributed over the interval [1000, 3000]? UN Ulo'lj 9000u+ [030
I’m bl[[noo, 2:533 —7\ Ema): 20013 In general, a uniformly distributed random variable U over the interval [0,1] can be trans—
formed into a uniformly distributed random variable over the interval [a, b] y umuro.o V: a+ mm in» wok/time? Question — How do we transform the random variable U into the bonus random variable B
that takes values {1, 2, . . . , 20} with equal probability? Here is a hard way of doing this. [0.00, 0.05)
[0.05, 0.10)
[0.10, 0.15)
[0.95, 1.00) if U < 2:15 B = 1 elseifU<o_r1 B=2 ‘ < all? = P
else 1fU _ B 3 u:o_(‘,1{' 7,314: 8.) Ezﬁ else if U <05 B = 19
else B = 20 . . . u o o : Do. u
The same computation can be succmctly carrled out by _ u m U‘ l“! O 2 U W l ’ 2 ‘l E _l
In Excel we can use =RDUNDUP (20*A1 , 0), assuming that the value of U is contained in cell A1. In general, a uniformly distributed random variable U over the interval [0,1] can be trans—
formed into a discrete uniform random variable over the integers {1, 2, ..., n} by [biAl Setting up a spreadsheet * We now have a method for generating samples of P and B.
The spreadsheet code for this calculation looks something like 3
16 In“
m >$2om
=RANDO =RANDO =1000+2000=1=B2 =ROUNDUPCC2*20,0) _ Recall that we want to estimate the expected winnings and the probability that the winnings
are at least $20000. We let PT, and Bar, be the prize and the bonus in replication n. We let W},
be the winning in replication 7; and keep track of this quantity in Column F. That is, it: = bun ea, Also, for each replication n, we check whether the winnings exceed $20000. In order to
do this, we deﬁne the random variable X as so ""1; O 0/“) w 71'3000 We let X“ denote whether the winnings in replication n exceed $20000. That is,
A 7/ Zoo 0
>6 ' “0 W
’0 0/0) In order to do this, Column G should include the formula
6 ‘. : We can now use the computer to replicate the experiment N times, yielding realizations FZ7/ 20000} [,0) of {l/Vn : n = 1,...,N} and {Xn : n : l,...,N}. Then, we can estimate the expected
winnings by H
mm t i... 2 Wm
H 4“! Question * How do we know that this method works? Law of large numbers w Let Z1, Z2, . . . be i.i.d. random variables with lEZ1 < 00. Then,
“almost always” 1 n
n i=1 as n, m; 00.
In our example, {Wu : n = 1, . . . ,N} have the same distribution as W and they are i.i.d.. More interestingly, we can estimate the probability that the winnings exceed $20000 by _ I"
XN t  E?“ >1“
N L' 17 This computation is also justiﬁed by the law of large numbers because n. 2 >6... 6* w w; i. WWW(12mm llWl N 11;, 1
c 7KZD°°°J Side note — Let MA) be the indicator random variable for event A. That is, MA) 2 1 if event A has occurred
0 otherwise. IE{1I(A)}=’L 1PM”; + o. iii/H: lw
IE{(I[(A))2}= l. Ill/0+ o. Ill/“l: LW? '2. wan/1)): E [WMle (“5510‘”) “" ml”? ‘ (ill/“)1 To shorten the discussion, we concentrate only on estimating lP’{W > 20000} from now on. Question — Every time we run the simulation model, our estimate of lP’{W > 20000} changes.
How conﬁdent can we be in our estimate? To assess the error, the standard approach is to construct a conﬁdence interval. This has
been discussed earlier. We will simply review the conclusion. 3. Fixed Sample Size Conﬁdence Intervals To produce an approximate 100(1 —— 00% conﬁdence interval for EX, 1. Select a sample size N.
2. Generate N i.i.d. samples X1,X2, . . . ,XN of X. 3. Compute the estimators c 1 N 1 N 7 2
XN=WéXm Siv=ﬂ;(Xn—XN) 4. Look up the value of Za/g such that
lP’{—za/2 g NU], 1) S Za/g} = 1 — a. 5. The approximate 100(1 — a)% conﬁdence interval for [EX is given by XN 3!: 205/2 This random interval will include EX approximately 100(1 — 00% of the time. 18 Emmple — A simulation run with 10 replications yields
{Xn : n: l,...,10} = {1,0,0,1,1,0,1,1,0, 1}. We have X10 = 0.6, sin 2 0.267. So, a 95% conﬁdence interval is 0.6 IF 1.96\/0.0267. Question — How large should N (the number of replications) be, so that we are reasonably
conﬁdent of our estimate in ]P’{W > 20000}? ' What we know about conﬁdence intervals is enough to answer this question. 4. Selecting the Sample Size Often, people prespecify the number of simulation runs to perform (N), and then carry out
the above analysis to determine a conﬁdence interval. This approach allows a reasonable
prediction of the computational effort required in the simulation, but gives no control on the
size of the resulting conﬁdence interval. We would like a method to estimate how large N
should be, so that the resulting 100(1 — 00% conﬁdence interval will have a prespeciﬁed width. The conﬁdence interval is of the form XNinu/g (ah/JV) , and the half—width of the interval is U
z —.
MW Set
If the desired half—width is 13, then we can set 2 r? 2
’g 336‘, , [7 =_ ,_ plﬂ. U“
m X {a “ to obtain a 100(1 — a)% conﬁdence interval with half—width 1?. However, the problem is
that 02 is usually unknown, and an estimate of 02 (that is, 3%.) can be obtained only after carrying out a certain number of simulation runs. One approach to overcome this problem is to perform some “trial runs.” We’ carry out A?
simulation runs (with, typically, 20 g k g 50) and let {X,’, : n : 1, . . . ,k} be the outcomes of
the trial runs. We compute XilkX’ 4— 1 k X’ X2 n) n.— Now, we can use ﬁg as an estimate of 0'2. If we want to ensure that the conﬁdence interval halfwidth is 1?, we pick N such that kl L ( Z an.  .y Emmple * Continuing with our previous example, suppose we want to estimate lEX with 19 2120.01 accuracy with 95% conﬁdence. We had, from 10 replications, E10 = 0.267. So we want to choose N 2 (g: guns/la) W J? N_ ML. W ' immaqL
'un / t t “m? " mm“ ‘ HA “I we 1»??? Relative precision intervals e Suppose now that we want to estimate lEX with a relative
accuracy of 1007 percent. That is, we want our conﬁdence interval to have a half—width of
'yllEX In this case, we estimate lEX by X k, and set the desired half—width of the conﬁdence interval to We pick N to satisfy
~ Etc 2 jg $1, 2
rleIZzaz— :4» N: (‘1 ~)
’ m an: Example — Continuing our previous example, suppose we want to estimate lEX with 425%
accuracy with 95% conﬁdence. We had, from 10 replications, X10 2 0.6, 53%, = 0.267. 80 we want to choose N 0.05 X 0.6 2 1.96 %7 => N 2 1139.67 => Pick N = 1140. Having computed a good value of N using these formulas, we carry out N additional
simulation runs and form a conﬁdence interval as described earlier from these N “production
runs.” Note that the ﬁnal conﬁdence interval may be wider or narrower than desired, because
the ﬁnal conﬁdence interval is constructed by using 8%, (obtained from the production runs). 2 312‘, may be larger or smaller than ﬁle. For the ﬁnal conﬁdence interval, the information from the “trial runs” is typically dis—
carded. This usually is not a problem, since N is typically much greater than the number of trial runs. There are procedures available, known as “two—stage” procedures, that try to
combine the data from the trial and production runs, but they are considerably more compli~ cated. 5. A Note on Accuracy Suppose that we want to double the accuracy of our conﬁdence interval — that is, halve the
conﬁdence interval half—width. How can we do this? Recall that the conﬁdence interval half—width is
0* za/ZW
Since 2042 and a are ﬁxed, we can increase the accuracy only by increasing N. Question — Suppose that N is given and a conﬁdence interval has already been computed. We
want to decrease the halfnwidth of the conﬁdence interval to half of its current value. How many simulation runs do we need? ‘33 We need four times as many replications to get twice the accuracy. Question e Assume that with N observations, the conﬁdence interval is 0.6273 2: 0.005 =
[0.6223, 0.6323]. If we want one more decimal place of accuracy, then how many simulation
runs do we need? 1AM 1mm 4' (“j 0'. L 7,43 "l: O. 990 5
. P P z‘a‘
0:00 5 e :z‘ E" 6 0,7900 ‘35 ”' W: W loo p.) For one more decimal place of accuracy, we need to run 100 times as many replications.
Therefore, if you want to obtain very accurate predictions through simulation, you may need
a huge number of simulation runs. 21 ...
View
Full
Document
This note was uploaded on 03/08/2012 for the course ORIE 4580 at Cornell University (Engineering School).
 '08
 TOPALOGLU

Click to edit the document details