Download DECISION MODELING WITH MICROSOFT EXCEL Chapter 9

Document related concepts

History of statistics wikipedia , lookup

Statistics wikipedia , lookup

Transcript
DECISION MODELING
WITH
MICROSOFT EXCEL
Chapter 9
Monte Carlo Simulation
Part 1
Copyright 2001
Prentice Hall Publishers and
Ardith E. Baker
Introduction
Simulation allows you to quickly and inexpensively
acquire knowledge concerning a problem that is usually
gained through experience (which is often costly and
time consuming).
An experimental device (simulator) will “act like”
(simulate) the system of interest in a quick, costeffective manner.
Goal: To create an environment in which
information about alternative actions can
be obtained through experimentation.
SIMULATION vs. OPTIMIZATION
In an optimization model, the values of the decision
variables are outputs.
The result of the model is a set of values for the
decision variables that will maximize (or minimize)
the value of the objective function.
In a simulation model, the values of the decision
variables are inputs. The model evaluates the
objective function for a particular set of values.
The result of the model is a measure of the quality
of a suggested solution and the variability in various
performance measures due to randomness in the
inputs.
When should simulation be used?
Simulation is one of the most frequently used tools of
quantitative analysis today because:
1. Analytical models may be difficult or impossible to
obtain, depending on complicating factors.
2. Analytical models typically predict only average or
“steady-state” (long-run) behavior.
3. Simulation can be performed with a variety of
software on a PC or workstation. The level of
computing and mathematical skill required to
design and run a simulator has been substantially
reduced.
Simulation and Random Variables
MONTE CARLO METHOD:
Simulation models are often used to analyze a decision
under risk. Under risk, the behavior of one or more
factors is not known with certainty. For example:
demand for a product during the next month
the return on an investment
the number of trucks that will arrive to be unloaded
The factor that is not known with certainty is called the
random variable.
The behavior of the random variable can be described
by a probability distribution.
Design of Docking Facilities. In the following model,
trucks of different sizes carrying different types of loads,
arrive at a warehouse to be unloaded.
T
r
u
c
k
D
o
c
k
3
T
r
u
c
k
D
o
c
k
2
T
r
u
c
k
D
o
c
k
1
Exit
Entrance
Truck waiting
Truck waiting
The uncertainties are:
When will a truck arrive?
What kind and size of load will it be carrying?
How long will it take to unload the trucks?
Each uncertain quantity would be a random variable
characterized by a probability distribution.
The planners must address a variety of design questions:
How many docks should be built?
What type and quantity of material-handling
equipment are required?
How many workers are required over what
periods of time?
The design of the unloading dock will affect its cost of
construction and operation. Management must balance
the cost of acquiring and using the various resources
against the cost of having trucks wait to be unloaded.
Determination of Inventory Control Policies. Simulation
can be used to study inventory control models.
Factory
Warehouse 1
Warehouse 2
Warehouse 3
Demand
Demand
Demand
In this model, the factory produces goods that are sent
to the warehouses to satisfy customer demand.
The random variables are: daily demand at each
warehouse and shipping times from factory to
warehouse.
Simulation can be used to study inventory control
models.
Some of the operational questions are:
When should a warehouse reorder from the
factory and how much?
How much stock should the factory maintain to
satisfy the orders of the warehouses?
The main costs are:
Cost of holding the inventory
Cost of shipping goods from a factory to a
warehouse
Cost of not being able to satisfy customer
demand at the warehouse
The objective is to find a stocking and ordering policy
that keeps the total cost low while meeting demand.
Generating Random Variables
To generate a random variable, draw a random sample
from a given probability distribution.
Two broad categories of random variables:
Discrete
Can assume only certain specific values (e.g.,
integers)
Continuous
Can take on any fractional value (an infinite
number of values)
The game spinner below is an example of a physical
device used to generate demand in a given model.
Once spun, the spinner is equally likely to point to any
point on the circumference of the circle.
13 (10.0%) 8 (10.0%)
12 (10.0%)
9 (20.0%)
11 (20.0%)
10 (30.0%)
If the areas of the sectors are made to correspond to the
probabilities of different demands, the spinner can be
used to simulate demand. Each spin represents a trial.
Using a Random Number
Generator in a Spreadsheet
Although easy to understand, the spinner method of
generating random numbers would be difficult to use if
thousands of trials are necessary. Therefore, random
number generators have been developed in
spreadsheets.
To generate demand for a given model, first assign a
range of random numbers to each possible demand.
To do this correctly, the proportion of total numbers
assigned to a demand must equal the probability of that
demand.
For example, using the interval from 0 to 1, make the
following assignment:
20% of the
interval is
assigned to 11
10% of the
interval is
assigned to 13
30% of the
interval is
assigned to 10
The probability of drawing a number in the range of
.90 to .99999 is 1 out of 10 or 0.1 (10%).
This method is useful for generating discrete random
variables.
A GENERALIZED METHOD:
To generate a discrete random variable with the RAND()
function in a spreadsheet, two things are needed:
1. The ability to generate discrete uniform random
variables
2. The distribution of the discrete random variable
to be generated
To generate a continuous random variable, two things
are needed:
1. The ability to generate continuous uniform
random variables on the interval 0 to 1
2. The distribution (in the form of the cumulative
distribution function) of the random variable to
be generated
Continuous Uniform Random Variables. It is important
to distinguish between U (the uniform random variable
on the interval 0 to 1) and u (a specific realization of that
random variable).
0
However, it is
impractical for
The game
a continuous
spinner can
distribution
.75
.25
be used to
since the exact
generate
point must be
values of U.
read
(e.g., .4999999
.5
999).
Every point on the circumference of the circle
corresponds to a number between 0 and 1.
The Cumulative Distribution Function (CDF). Consider a
random variable, D, the demand. The CDF for D [called
F(x)] is then defined as the probability that D takes on a
value < x.
F(x) = Prob{D < x}
Knowing the probability distribution for D, the CDF for
key values of D is:
X
F(x)
8
0.1
9
0.3
10
0.6
11
0.8
12
0.9
13
1.0
With a continuous distribution, the probability that any
specific value occurs is 0. Therefore, continuous
random variables do not have probability distributions.
They are defined by the density function and the CDF.
Here is a graph of the CDF. To generate a discrete
demand using the graph:
Probability
1.2
Step 1: Locate
the particular
value of U on
this axis
1
0.8
0.6
F(x)
u
Step 2: Read the
particular value
of the random
quantity, d, on
this axis
0.4
0.2
d
x
0
7
8
9
10
11
12
13
14
Suppose you want to model a discrete uniform
distribution of demand where the values of 8 through 12
all have the same probability of occurring (uniform,
equally likely).
The spreadsheet has a function, =RAND(), that returns a
random number between 0 and 1. However, this will
result in a continuous uniform distribution.
To create a discrete uniform distribution, use the INT()
function. For example:
In general, if you want a discrete, uniform distribution of
integer values between x and y, use the formula:
INT(x + (y – x + 1)*RAND() )
THE GENERAL METHOD
APPLIED TO CONTINUOUS DISTRIBUTIONS:
The two-step process for generating a continuous
random variable W is shown below:
The cumulative
Probability
1.1
1
F(x)=Prob{W<x}
distribution
function of W
u
0.9
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
As before, first
locate the value (u)
of the random
variable U
F(w)
w
0
1
2
3
4
5
6
7
8
9
x
10
Then, read the
particular value of
the random
quantity, W, on
this axis
Generating from the Exponential Distribution. The
exponential distribution is often used to model the time
between arrivals in a queuing model. Its CDF is given by:
F(x) = Prob{W < w} = 1 – e-lw
Where 1/l is the mean of the random variable W.
Therefore, we want to solve the following equation for w:
u = 1 – e-lw
The solution is:
w = -1/l ln(1- u)
Now, to draw a sample from an exponential distribution
with a mean of 20 (1/l) using this equation:
1. First generate a continuous, uniform random
number with RAND() (for example, .75).
2. Apply the formula: w = -1/l ln(1- u)
= -20 (ln(1- .75))
= -20 (-1.386)
= 27.72
In a spreadsheet cell, simply enter:
= -20 *LN(1 – RAND() )
Generating from the Normal Distribution. The normal
distribution plays an important role in many simulation
and analytic models. Normality is often assumed.
Consider drawing a random demand from a normal
distribution with a mean (m) of 1000 and a standard
deviation (s) of 100.
If Z is a unit normal random variable (normally
distributed with a mean of 0 and a standard deviation of
1) then m + Zs is a normal random variable with mean m
and standard deviation s.
So, we can draw from a unit normal distribution. Excel
has a built-in function that can do this:
= NORMINV( RAND() , 1000, 100)
Excel will automatically return a normally distributed
random number with mean 1000 and std. dev. 100.
Simulating with a Spreadsheet
Simulations can be performed with spreadsheets alone.
However, add-in software packages can enhance the
capabilities of Excel.
Two Excel add-in packages that will be used are Crystal
Ball and @Risk.
These add-ins offer additional random distributions and
easy commands to set up and run many more iterations
than could be run in Excel.
In addition, they automatically gather statistical and
graphical summaries of the results.
A CAPITAL BUDGETING EXAMPLE:
ADDING A NEW PRODUCT LINE
Airbus Industry is considering adding a new jet airplane
(model A3XX) to its product line. The following financial
information is available:
Startup Costs
Sales Price
Fixed Costs (per year)
Variable Costs (per year)
$150,000
$ 35,000
$ 15,000
75% of revenues
Tax depreciation on the new equipment would be
$10,000 per year over the 4 year expected product life.
Salvage value of the equipment at the end of the 4 years
is estimated to be 0.
Airbus’ cost of capital is 10% and tax rate is 34%.
If demand is known, then a spreadsheet can be used to
calculate the net present value (NPV). For example,
assume that the demand for A3XXs is 10 units for each
of the next 4 years:
=C9*$B$3
=$B$4
=C10*$D$2
=$B$5
=C10-SUM(C11:C13)
=$D$4*C14
=C14 – C15
=C16 + C13
=NPV($D$3,C17:F17)+B17
=-$B$2
THE MODEL WITH RANDOM DEMAND
It is unlikely that demand will be the same every year. A
more realistic model would be one in which demand
each year is a sequence of random variables.
This model of demand is appropriate when there is a
constant base level of demand that is subject to random
fluctuations from year to year.
Sampling Demand with a Spreadsheet: Assume initially
that the demand in a year will be either 8, 9, 10, 11, or 12
units with each value being equally likely to occur.
This is an example of a discrete uniform distribution.
Now, use the formula =INT(8 + 5*RAND() ) to sample
from a discrete uniform distribution on the integers 8, 9,
10, 11, 12 .
Multiple trials can be performed by pressing the
recalculation key for the spreadsheet (e.g., F9).
Using this formula results in random demands.
=INT(8+5*RAND() )
Hitting the F9 key would result in a different sample of
demands, and possibly a different NPV.
The demands are random variables, therefore, the NPV
is also a random variable.
EVALUATING THE PROPOSAL
Two questions need to be answered about the NPV
distribution:
1. What is the mean or expected value of the NPV?
2. What is the probability that the NPV assumes a
negative value (making the proposal to add the
A3XX less attractive)?
To answer these questions, a simulation model must be
built. To run the simulation automatically and capture
the resulting NPV in a separate spreadsheet, use the
Data Table command.
Start with a blank worksheet by clicking on the Insert
menu and select Worksheet
Next, rename this blank worksheet 100 Iterations
Type the starting value (1) in cell A2 and hit Enter, then
return to cell A2.
Click the Edit menu and
choose Fill – Series.
In the resulting dialog, select
Series in Columns and enter a
stop value of 100. Click OK to
fill series.
Add column titles and the following formula to cell B2.
Now select the range A2:B101 and click Data – Table.
In the resulting dialog, enter C1 for the column input cell
and click OK.
Excel will recalculate
the values and store the
resulting NPV in the
adjacent cells in column
B.
Note that since a random
number generator is used in
the formula, you may get
different values than these.
Now, to turn the formulas into actual values upon which
we can focus, first select the range of cells B2:B101,
then click on the Edit – Copy menu.
Next, click on the Edit – Paste
Special menu option and in the
resulting dialog, choose Values.
To get a summary of the 100 iterations, use Excel’s builtin data analysis tool. Click on Tools – Data Analysis.
If you do not have this option, click on the Add-in option
on the Tools menu and in the resulting dialog, click on
Analysis ToolPak.
After clicking OK, the Data
Analysis dialog will open.
Select the Descriptive
Statistics option and click
OK.
In the resulting dialog, choose the Input Range to
include the 100 iterations.
Now click
on Output
Range and
enter the
cell where
the output
will be
placed.
In addition,
select
Summary
Statistics
and click
OK.
The resulting analysis gives the estimated mean NPV
and standard deviation.
Downside Risk and Upside Risk: To get a better idea
about the range of possible NPVs that could occur, look
at the minimum and maximum NPVs.
Distribution of Outcomes: Now we ask the question:
How likely will these extreme outcomes occur?
To answer this, examine the shape of the distribution of
the NPV by creating a histogram.
Click on Tools – Data Analysis and choose Histogram.
In the resulting dialog, set
the input range and
choose to save the results
in a worksheet called NPV
Distribution.
In the resulting analysis, the Frequency (column B)
indicates the number of trials that fell into the bins
(categories) defined by column A.
The cumulative % column indicates the cumulative
percentage of observations that fall into each category
or bin.
The histogram gives a visual representation of the
distribution of NPVs. Note that it is somewhat bell
shaped.
How Reliable is the Simulation? Now the two questions
about the distribution can be answered:
1. What is the mean or expected value of the NPV?
In this trial, the mean is $12,100.
2. What is the probability that the NPV assumes a
negative value (making the proposal to add the
A3XX less attractive)?
In this trial, the probability is >15%.
The next questions to ask are:
1. How much confidence do we have in the answers
from the first trial?
2. Would we be more confident if we ran more trials?
For a 95% confidence interval, the formula is:
estimated mean + 1.96(standard deviation)
In this case, the standard deviation is the standard error
(the standard deviation divided by the square root of the
number of trials).
Based on this trial, the upper and lower confidence
limits are:
=$E$4-1.96*$E$8/SQRT($E$16)
=$E$4+1.96*$E$8/SQRT($E$16)
So, we have 95% confidence that the true mean NPV is
somewhere between $9,679 and $14,521.
Simulating with Spreadsheet Add-ins
Spreadsheet add-ins such as Crystal Ball and @Risk
simplify the process of generating random variables and
assembling the statistical results.
To illustrate, return to the capital budgeting example.
A CAPITAL BUDGETING EXAMPLE:
ADDING A NEW PRODUCT LINE
Airbus Industry is considering adding a new jet airplane
(model A3XX) to its product line. The following financial
information is available:
Startup Costs
Sales Price
Fixed Costs (per year)
Variable Costs (per year)
$150,000
$ 35,000
$ 15,000
75% of revenues
Tax depreciation on the new equipment would be
$10,000 per year over the 4 year expected product life.
Salvage value of the equipment at the end of the 4 years
is estimated to be 0.
Airbus’ cost of capital is 10% and tax rate is 34%.
If demand is known, then a spreadsheet can be used to
calculate the net present value (NPV). For example,
assume that the demand for A3XXs is 10 units for each
of the next 4 years:
=C9*$B$3
=$B$4
=C10*$D$2
=$B$5
=C10-SUM(C11:C13)
=$D$4*C14
=C14 – C15
=C16 + C13
=NPV($D$3,C17:F17)+B17
=-$B$2
THE MODEL WITH RANDOM DEMAND
It is unlikely that demand will be the same every year. A
more realistic model would be one in which demand
each year is a sequence of random variables.
This model of demand is appropriate when there is a
constant base level of demand that is subject to random
fluctuations from year to year.
Sampling Demand with a Spreadsheet: Assume initially
that the demand in a year will be either 8, 9, 10, 11, or 12
units with each value being equally likely to occur.
This is an example of a discrete
uniform distribution.
Enter the discrete distribution
in a two-column format for
Crystal Ball to be able to use it.
After installing Crystal Ball, an additional toolbar will be
displayed in Excel.
Place your cursor in cell C9 and click on the Define
Assumption button.
Click Custom in the
resulting dialog.
Click Ok to open the
Custom Distribution
dialog.
Click on the Data
button.
Enter the cell range in which the discrete distribution
resides and click OK.
The resulting distribution will be displayed:
Click OK again
to accept.
Repeat these steps for years 2-4 (cells D9:F9) or use
Crystal Ball’s copy data
and paste data
icons.
To get Crystal Ball to draw a new random sample of
demands, simply click on the Single Step icon.
Clicking on this button will
randomly change the demand
and the NPV, since each is a
random variable.
EVALUATING THE PROPOSAL
In order to answer the two questions about the NPV
distribution:
1. What is the mean or expected value of the NPV?
2. What is the probability that the NPV assumes a
negative value (making the proposal to add the
A3XX less attractive)?
We need to run the simulation automatically a number of
times and capture the resulting NPV.
To do this using Crystal Ball, first set up the base case
model and enter the RNGs (Random Number Generators)
in cells C9:F9 as was previously illustrated.
(Wilscb1c.xls)
Next, click
on B19 (the
NPV cell)
and then on
the Define
Forecast
button.
After clicking on the Define Forecast icon, the following
dialog will appear:
Click on the Large
forecast window size
and When Stopped
(faster) display option
in this dialog. Click
Set Default and then
click OK.
Click on the Run
Preferences
icon to
change the Maximum
Number of Trials to 500
and click OK.
To begin the simulation, click on the Start Simulation
button.
The following dialog will be displayed upon completion
of the 500 iterations.
Clicking OK will automatically
produce a histogram.
To look at the statistics from the simulation, click on
View menu on the histogram and click on Statistics.
Each run of the simulation will produce different
numbers so your results may not match those shown
here.
Downside Risk and Upside Risk: To get an idea of the
range of possible NPVs that could occur, look at the
minimum and maximum values in the statistic results.
Distribution of Outcomes: In order to answer other
questions about the distribution of NPVs, we need to
look at the shape of the distribution.
The previous histogram (which was automatically
produced) gives a graphical view of the distribution.
The shape of the distribution is definitely bell-shaped.
Other information can be requested from Crystal Ball.
For example, suppose you want to determine the exact
probability that the NPV will be non-positive (< 0).
In the Crystal Ball histogram window, enter 0 in the cell
in the lower right corner and hit enter.
19.2 % of the
observed NPV
values were
less than or
equal to 0.
Click on View – Percentiles in the Crystal Ball window to
display the percentiles of the NPV distribution.
How Reliable is the Simulation? Now that the questions
concerning the mean of the distribution and the
probability of negative values has been determined, the
next questions to answer are:
How much confidence do we have in these
answers?
Would we have more confidence if we ran more
trials?
We can have 95%
confidence that the
true mean will fall in an
interval of + 1.96
standard deviations
about the estimated
mean.
OTHER DISTRIBUTIONS OF DEMAND
Originally, we started with equal mean demands of 10 for
each period (year). Then, we allowed for random
variation in mean demand (between 8 and 12 units).
Now, assume the mean demand will stay the same over
the next four years, somewhere between 6 and 14 units a
year, with all values being equally likely.
This scenario can be modeled as a continuous, uniform
distribution between 6 and 14.
In addition, we can explore the impact of different
demand distributions on the NPV. When the mean
demand is relatively small, a distribution called the
Poisson distribution is often a good fit.
The Poisson distribution is a one-parameter distribution.
Specifying the mean of this distribution completely
determines it.
The Poisson distribution is a discrete distribution and
the Poisson random variable can only take on nonnegative integer values.
Using Crystal Ball’s Distribution Gallery, we can easily
sample from a discrete Poisson distribution or from a
continuous uniform distribution.
First, indicate in Crystal Ball that the cell D6 will have the
uniform distribution and that cells C9:F9 will have a
Poisson distribution with a mean value driven by the
value in cell D6. (Wilsncb2.xls)
With your cursor on cell D6, click on the Define
Assumptions icon and choose Uniform as the
distribution. Click OK.
In the resulting dialog, specify the range of the
distribution to be a minimum of 6 and a maximum of 14,
then click OK.
To specify the Poisson distribution, first select cell C9
then click on the Define Assumption icon
. In the
resulting dialog, select Poisson and click OK.
In the distribution’s dialog, specify the lower range to be
–Infinity and the Rate to be =$D$6.
Clicking Enter will display the Static and Dynamic
options. Click on Dynamic and then click OK.
Use the Copy Data
and Paste Data
transfer the information to cells D9:F9.
icons to
Now, let’s base the estimates on a sample of 1000 from
the distribution of the NPV.
Click on the Run Preferences
following dialog box:
icon to open the
Change the Maximum
Number of Trials to
1000 and click OK.
Click on the Define Forecast
icon to capture the
NPV in cell B19 for each of the iterations.
Now, click on the Reset Simulation
previous results.
icon to clear any
Click on the Start Simulation
icon to begin. After
1000 iterations are completed, a histogram will be
displayed.
Click on View –
Statistics to bring up
the descriptive
statistics dialog.
Note that these
results may differ
from yours.
Based on these results, the probability of a negative
NPV is 44.2%.
In summary,
1. Increasing the number of trials is apt to give a
better estimate of the expected return. However,
there can still be a difference between the
simulated average and the true expected return.
2. Simulations can provide useful information on the
distribution results.
3. Simulation results are sensitive to assumptions
affecting the input parameters.
End of Part 1
Please continue to Part 2