Upload
henry
View
74
Download
0
Tags:
Embed Size (px)
DESCRIPTION
Session 7a. Overview. Monte Carlo Simulation Basic concepts and history Excel Tricks RAND(), IF, Boolean Crystal Ball Probability Distributions Normal, Gamma, Uniform, Triangular Assumption and Forecast cells Run Preferences Output Analysis Examples - PowerPoint PPT Presentation
Citation preview
Session 7a
Decision Models -- Prof. Juran
2
OverviewMonte Carlo Simulation
– Basic concepts and historyExcel Tricks
– RAND(), IF, BooleanCrystal Ball
– Probability Distributions • Normal, Gamma, Uniform, Triangular
– Assumption and Forecast cells– Run Preferences– Output Analysis
Examples– Coin Toss, TSB Account, Preventive Maintenance,
NPV
Decision Models -- Prof. Juran
3
Decision Models: 2 Modules
• Module I: Optimization• Module II: Spreadsheet Simulation
Decision Models -- Prof. Juran
4
Monte Carlo SimulationUsing theoretical probability distributions to model real-world situations in which randomness is an important factor.
Differences from other spreadsheet models• No optimal solution• Explicit modeling of random variables in
special cells• Many trials, all with different results• Objective function studied using statistical
inference
Decision Models -- Prof. Juran
5
Decision Models -- Prof. Juran
6
Decision Models -- Prof. Juran
7
Decision Models -- Prof. Juran
8
Decision Models -- Prof. Juran
9
Decision Models -- Prof. Juran
10
Decision Models -- Prof. Juran
11
Decision Models -- Prof. Juran
12
Origins of Monte Carlo
Stanislaw M. Ulam (1909 - 1984)
Nicholas Metropolis (1915-1999)
Decision Models -- Prof. Juran
13
Example: Coin TossImagine a game where you flip a coin once. If you get “heads”, you win $3.00 If you get “tails”, you lose $1.00The coin is not fair; it lands on “heads” 35% of the timeWhat is the expected value of this game?
Decision Models -- Prof. Juran
14
Simulation “By Hand”Set up a spreadsheet modelAdd an element of randomness
• Excel built-in random number generator• Use F9 key to create repetitive iterations of
the random system (“realizations”)Keep track of the results
Decision Models -- Prof. Juran
15
1234
A B C D E
Random # 0.2002Outcome HeadProfit $3.00
=RAND()=IF(B2<0.35,"Head","Tail")=IF(B2<0.35,3,-1)
Decision Models -- Prof. Juran
16
What Does =RAND() Do?Uniform random number between 0 and 1Never below 0; never above 1All values between 0 and 1 are equally likely
P(X<0.35) = 0.35
0.35 0.65
Decision Models -- Prof. Juran
17
What Does =IF Do?Evaluates a logical expression (true or false)Gives one result for true and a different result for falseIn our “coin” model, RAND and IF work together to generate heads and tails (and profits and losses) from a specific probability distribution
1234
A B C D E
Random # 0.7438Outcome TailProfit -$1.00
=RAND()=IF(B2<0.35,"Head","Tail")=IF(B2<0.35,3,-1)
Decision Models -- Prof. Juran
18
Some Random Results
123456789
1011121314151617
A B C D E FRandom # Outcome Profit
0.4619 Tail -$1.000.4118 Tail -$1.000.5815 Tail -$1.000.9792 Tail -$1.000.2852 Head $3.000.9064 Tail -$1.000.9855 Tail -$1.000.9988 Tail -$1.000.2206 Head $3.000.0986 Head $3.000.9696 Tail -$1.000.8026 Tail -$1.000.8189 Tail -$1.000.7137 Tail -$1.000.9258 Tail -$1.00
-$0.20 =AVERAGE(C2:C16)
123456789
1011121314151617
A B C D E FRandom # Outcome Profit
0.1979 Head $3.000.9185 Tail -$1.000.4688 Tail -$1.000.6670 Tail -$1.000.0902 Head $3.000.3757 Tail -$1.000.1492 Head $3.000.4518 Tail -$1.000.8503 Tail -$1.000.1392 Head $3.000.1924 Head $3.000.0179 Head $3.000.4799 Tail -$1.000.5064 Tail -$1.000.3051 Head $3.00
$0.87 =AVERAGE(C2:C16)
Sample means from 15 trials:
Decision Models -- Prof. Juran
19
Problems with this ModelHitting F9 thousands of times is tediousKeeping track of the results (and summary statistics) is even more tediousWhat if we want to simulate something other than a uniform distribution between 0 and 1?
Decision Models -- Prof. Juran
20
Simulation with Crystal Ball
Special cells for random variables (Assumptions)
Special cells for objective functions (Forecasts)
Run Preferences • Number of trials• Random number seed• Sampling method
Output Analysis• Studying forecasts• Extracting data
Decision Models -- Prof. Juran
21
Assumption CellAn input random number; a building block for a simulation model
The “Define Assumption” button:
Must be a “value” cell (a number, not a function)Can be ANY numberGives Crystal Ball permission to generate random numbers in that cell according to a specific probability distribution
Decision Models -- Prof. Juran
22
Decision Models -- Prof. Juran
23
Decision Models -- Prof. Juran
24
123456
A B C D
Random # 0.5000Outcome TailProfit -$1.00
Decision Models -- Prof. Juran
25
Keeps track of important outcome cells during the simulation run. Select the “profit” cell and click on the forecast button.
You can enter a name and units if you want. Then click OK.
Assumption Cell
Decision Models -- Prof. Juran
26
Decision Models -- Prof. Juran
27
Now click on the run preferences button.
Decision Models -- Prof. Juran
28
Play Stop Rewind Single Step
Crystal Ball has buttons for controlling the simulation run, similar to the buttons on a DVD player:
Decision Models -- Prof. Juran
29
The “play” button
The Crystal Ball toolbar:
Decision Models -- Prof. Juran
30
Decision Models -- Prof. Juran
31
The simulation will run until it reaches the maximum number of trials, at which point it will display this message:
Decision Models -- Prof. Juran
32
Crystal Ball performs the tedious functions of running a simulation in a spreadsheet modelWe can use statistical inference (confidence intervals and hypothesis tests) to study the resultsThe results are only estimates, but they can be very precise estimatesMuch depends on the validity of our model; how well it represents the real-world system we really want to learn about
Conclusions
Decision Models -- Prof. Juran
33
Built into Excel• RAND() function• Tools – Data Analysis – Random Number
GenerationBuilt into all simulation softwareNot really random; correctly called pseudo-
random
Random Number Generator
Decision Models -- Prof. Juran
34
Needs a “seed” to get started
Each random number becomes the “seed” for its successor
Random Number Generator
Decision Models -- Prof. Juran
35
Example: Tax-Saver Benefit
A TSB (Tax Saver Benefit) plan allows you to put money into an account at the beginning of the calendar year that can be used for medical expenses. This amount is not subject to federal tax — hence the phrase TSB.
Decision Models -- Prof. Juran
36
As you pay medical expenses during the year, you are reimbursed by the administrator of the TSB until the TSB account is exhausted. From that point on, you must pay your medical expenses out of your own pocket. On the other hand, if you put more money into your TSB than the medical expenses you incur, this extra money is lost to you.
Your annual salary is $50,000 and your federal income tax rate is 30%.
Decision Models -- Prof. Juran
37
Assume that your medical expenses in a year are normally distributed with mean $2000 and standard deviation $500.
Build a Crystal Ball model in which the output is the amount of money left to you after paying taxes, putting money in a TSB, and paying any extra medical expenses. Experiment with the amount of money put in the TSB, and identify an amount that is approximately optimal.
Decision Models -- Prof. Juran
38
First, we set up a spreadsheet to organize all of the information. In particular, we want to make sure we’ve identified the decision variable (how much to have taken out of our salary and put into the TSB account — here in cell B1), the objective (Maximize net income — after tax, and after extra medical expenses not covered by the TSB — which we have here in cell B14), and the random variable (in this case the amount of medical expenses — here in cell B9).
Decision Models -- Prof. Juran
39
123456789
1011121314151617
A B C DTSB Amount (Decision Var iable) 2,000.00$
Annual Salary 50,000.00$ Tax Rate 30%After TSB Income 48,000.00$ Taxes Owed 14,400.00$ Net Income Before Medical Expenses 33,600.00$
Tota l Medical Expenses 2,000.00$ Amount in TSB 2,000.00$ Expenses Not Covered (Must Be Paid Out-Of-Pocket) -$ Money Left Over in TSB (Lost) -$
Net Income After Medical Expenses (Objective) 33,600.00$
Mean 2,000.00$ Standard Deviation 500.00$
=B3-B1
=B5* B4
=B5-B6
This will be a random variable.
=B1
=MAX(B9-B10,0)
=MAX(B10-B9,0)
=B7-B11
Decision Models -- Prof. Juran
40
Note (this is important): We will never get a simulation model to tell us directly what is the optimal value of the decision variable.
We will try different values (here we have arbitrarily started with $2000 in cell B1) and see how the objective changes.
Through educated trial-and-error, we will eventually come to some conclusion about what is the best amount of money to put into the TSB account.
Decision Models -- Prof. Juran
41
Now we add the element of randomness by making B9 into an assumption cell. First, enter the mean and standard deviation for the medical expenses random variable (we put them in cells B16 and B17, respectively).
1617
A BMean 2,000.00$ Standard Deviation 500.00$
Decision Models -- Prof. Juran
42
Select the assumption cell B9 and click on the assumption button.
Select “Normal” and click “OK”.
Decision Models -- Prof. Juran
43
We are presented with a screen where we can enter the parameters for this normal distribution. We can enter values (2000 and 500) or we can use cell references. Here we enter the cell references.
Decision Models -- Prof. Juran
44
89
101112
A B C
Total Medical Expenses 2,339.74$ Amount in TSB 3,000.00$ Expenses Not Covered (Must Be Paid Out-Of-Pocket) -$ Money Left Over in TSB (Lost) 660.26$
Decision Models -- Prof. Juran
45
Now we need to tell Crystal Ball to keep track of our objective cell during all of our simulation runs, so we can see its mean and standard deviation over many trials. Select the net income cell B14 and click on the forecast button.
You can enter a name and units if you want. Then click OK.
Decision Models -- Prof. Juran
46
131415
A B C
Net Income After Medical Expenses (Objective) 32,900.00$
Decision Models -- Prof. Juran
47
Now click on the run preferences button.
Decision Models -- Prof. Juran
48
Decision Models -- Prof. Juran
49
Now click on the “start” button:
The simulation will run until it reaches the maximum number of trials, at which point it will display this message:
Decision Models -- Prof. Juran
50
Decision Models -- Prof. Juran
51
Decision Models -- Prof. Juran
52
To see the summary statistics from the 1000 simulations, we click on the extract data button.
Select one of the options (here we pick statistics):
Decision Models -- Prof. Juran
53
We see the following information appear in a new worksheet:
This gives us everything we need to perform analysis such as making a confidence interval for the true mean net income when we put $2000 into the TSB account.
123456789
1011121314
A BStatistics Net Income After Medical Expenses (Objective)
Trials 1000Mean $33,400.20 Median $33,599.70 Mode $33,600.00 Standard Deviation $293.71 Variance $86,267.79 Skewness -1.69Kurtosis 5.84Coeff. of Variabil ity 0.0088Minimum $31,701.96 Maximum $33,600.00 Range Width $1,898.04 Mean Std. Error $9.29
Decision Models -- Prof. Juran
54
The formula for a 95% confidence interval:
To perform normal distribution calculations in Excel, we use the NORMSDIST and NORMSINV functions.
nszX 2
Decision Models -- Prof. Juran
55
NORMSDIST
123
A B C D E
Lower Tail Area 0.9332z-value 1.500
=NORMSDIST(B3)
Decision Models -- Prof. Juran
56
NORMSINV
123
A B C D
Lower Tail Area 0.05z-value -1.645 =NORMSINV(B2)
Decision Models -- Prof. Juran
57
95% Confidence Interval for the Population Mean
nszX 2
123456789
1011121314
A B C D E F G HStatistics Net Income After Medical Expenses (Objective)
Trials 1000 Alpha 0.05Mean $33,400.20 z-value 1.960Median $33,599.70 Mode $33,600.00 LCL $33,382.00 Standard Deviation $293.71 UCL $33,418.41 Variance $86,267.79 Skewness -1.69Kurtosis 5.84Coeff. of Variabil ity 0.0088Minimum $31,701.96 Maximum $33,600.00 Range Width $1,898.04 Mean Std. Er ror $9.29
=NORMSINV(1-(E2/2))
=B3-E3*B14=B3+E3*B14
Decision Models -- Prof. Juran
58
Unfortunately, we can’t tell whether $2000 is the optimal amount without trying many other possible amounts. This could entail a long and tedious series of simulation runs, but fortunately it is possible to test many values at once.
We set up numerous columns in the worksheet, so that we can perform simulation experiments on many possible TSB amounts simultaneously:
1234567891011121314151617
A B C D E F G H I JTSB Amount (Decision Variable) 1,000$ 1,250$ 1,500$ 1,750$ 2,000$ 2,250$ 2,500$ 2,750$ 3,000$
Annual Salary 50,000$ 50,000$ 50,000$ 50,000$ 50,000$ 50,000$ 50,000$ 50,000$ 50,000$ Tax Rate 30% 30% 30% 30% 30% 30% 30% 30% 30%After TSB Income 49,000$ 48,750$ 48,500$ 48,250$ 48,000$ 47,750$ 47,500$ 47,250$ 47,000$ Taxes Owed 14,700$ 14,625$ 14,550$ 14,475$ 14,400$ 14,325$ 14,250$ 14,175$ 14,100$ Net Income Before Medical Expenses 34,300$ 34,125$ 33,950$ 33,775$ 33,600$ 33,425$ 33,250$ 33,075$ 32,900$
Total Medical Expenses 2,675.05$ Amount in TSB 1,000.00$ 1,250.00$ 1,500.00$ 1,750.00$ 2,000.00$ 2,250.00$ 2,500.00$ 2,750.00$ 3,000.00$ Expenses Not Covered (Must Be Paid Out-Of-Pocket) 1,675.05$ 1,425.05$ 1,175.05$ 925.05$ 675.05$ 425.05$ 175.05$ -$ -$ Money Left Over in TSB (Lost) -$ -$ -$ -$ -$ -$ -$ 74.95$ 324.95$
Net Income After Medical Expenses (Objective) 32,624.95$ 32,699.95$ 32,774.95$ 32,849.95$ 32,924.95$ 32,999.95$ 33,074.95$ 33,075.00$ 32,900.00$
Mean 2,000.00$ Standard Deviation 500.00$
Decision Models -- Prof. Juran
59
Here we have set up different columns, each with its own possible amount to be put into the TSB account in row 1. In row 14 we have the net income forecast for each possible value of the decision variable.
To make the output easy to interpret, we had to select each forecast cell, click on the “define forecast” button, and give each of them a logical name. This is a pain, but it pays off later.
Decision Models -- Prof. Juran
60
Now we re-run the simulation, click on extract data, select “all” forecasts, and get summary statistics for all of our possible values for the TSB:
1234567891011121314
A B C D E F G H I J KStatistics $1000 $1250 $1500 $1750 $2000 $2250 $2500 $2750 $3000 $3250
Trials 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000Mean $33,314.57 $33,378.53 $33,425.38 $33,440.97 $33,411.55 $33,334.34 $33,214.52 $33,064.00 $32,897.02 $32,724.66Median $33,324.43 $33,399.43 $33,474.43 $33,549.43 $33,600.00 $33,425.00 $33,250.00 $33,075.00 $32,900.00 $32,725.00Mode $34,300.00 $34,125.00 $33,950.00 $33,775.00 $33,600.00 $33,425.00 $33,250.00 $33,075.00 $32,900.00 $32,725.00Standard Deviation $481.84 $462.07 $422.72 $359.41 $276.89 $190.27 $115.05 $61.44 $26.15 $6.62Variance $232,173.49 $213,508.34 $178,691.94 $129,178.73 $76,666.31 $36,202.62 $13,235.87 $3,774.51 $683.68 $43.80Skewness -0.07 -0.25 -0.54 -0.97 -1.59 -2.55 -4.17 -6.68 -10.98 -20.99Kurtosis 2.62 2.49 2.57 3.21 5.06 9.77 22.23 51.79 138.39 466.46Coeff. of Variability 0.01 0.01 0.01 0.01 0.01 0.01 0.00 0.00 0.00 0.00Range Minimum $31,886.47 $31,961.47 $32,036.47 $32,111.47 $32,186.47 $32,261.47 $32,336.47 $32,411.47 $32,486.47 $32,561.47Range Maximum $34,300.00 $34,125.00 $33,950.00 $33,775.00 $33,600.00 $33,425.00 $33,250.00 $33,075.00 $32,900.00 $32,725.00Range Width $2,413.53 $2,163.53 $1,913.53 $1,663.53 $1,413.53 $1,163.53 $913.53 $663.53 $413.53 $163.53Mean Std. Error $15.24 $14.61 $13.37 $11.37 $8.76 $6.02 $3.64 $1.94 $0.83 $0.21
Decision Models -- Prof. Juran
61
TSB Simulation Analysis Results
$32,500
$32,600
$32,700
$32,800
$32,900
$33,000
$33,100
$33,200
$33,300
$33,400
$33,500
$1000 $1250 $1500 $1750 $2000 $2250 $2500 $2750 $3000 $3250
Amount Put Into TSB Account
Mea
n N
et In
com
e
Decision Models -- Prof. Juran
62
What if we assume that annual medical expenses follow a gamma distribution?
To have the same mean and standard deviation as our normal distribution, we would use $0 for the location parameter, $125 for the scale parameter (sometimes symbolized with β), and 16 for the shape parameter (sometimes symbolized with ).
Decision Models -- Prof. Juran
63
Gamma vs. Normal
$0 $1,000 $2,000 $3,000 $4,000 $5,000
Medical Expense
Prob
abili
ty
Gamma Distribution Normal Distribution
Decision Models -- Prof. Juran
64
Decision Models -- Prof. Juran
65
TSB Simulation Analysis Results
$32,500
$32,600
$32,700
$32,800
$32,900
$33,000
$33,100
$33,200
$33,300
$33,400
$33,500
$1000 $1250 $1500 $1750 $2000 $2250 $2500 $2750 $3000 $3250
Amount Put Into TSB Account
Mea
n N
et In
com
e
Decision Models -- Prof. Juran
66
Conclusions• The best amount to put into the TSB is
apparently about $1,750 per year.• This result is robust over different
distributions of medical costs.• This result is based on sample statistics,
not known population parameters.• We have confidence in these sample
statistics because of the large sample size (1,000).
Decision Models -- Prof. Juran
67
Probability Trick: Uniform to Normal
1234567891011121314
A B C DParameters for Uniform
Min Max0 1
0.5000 Uniform
0.0000 Standard Normal
Parameters for NormalMean StDev
0.6659% 2.9679%
Normal0.6659% (Forecast)
=NORMSINV(A5)
=B11+A7*C11
Start with template file: s-uniform-normal-0.xls