Monte Carlo Risksim
Monte Carlo Risksim
Monte Carlo Risksim
Contents
(1) Start Excel, and use Excel’s File | Open command to open the RiskSim XLA file from floppy or
hard drive.
(2) Copy the RiskSim XLA file to the Excel | Library subdirectory of your hard drive. Start Excel,
and use Excel’s Tools | Add-Ins command to load and unload RiskSim as needed.
(3) Copy the RiskSim XLA file to the Excel | Startup subdirectory of your hard drive, in which case
the file will be opened every time you start Excel.
All of RiskSim’s functionality, including its built-in help, is a part of the RiskSim XLA file. There is
no separate setup file or help file.
(A) First, use your file manager to locate the RiskSim XLA file, and delete the file from your hard
drive.
(B1) If RiskSim is listed under Excel's add-in manager and the box is checked, when you start Excel
you'll see "Cannot find ..." Click OK. Choose Tools | Add-Ins, uncheck the box for RiskSim; you'll
see "Cannot find ... Delete from list?" Click Yes.
(B2) If RiskSim is listed under Excel's add-in manager and the box is not checked, start Excel and
choose Tools | Add-Ins. Check the box for RiskSim; you'll see "Cannot find ... Delete from list?"
Click Yes.
Overview
RiskSim is a Monte Carlo Simulation add-in for Microsoft Excel 97 (and later versions of Excel) for
Windows and Macintosh.
RiskSim provides random number generator functions as inputs for your model, automates Monte
Carlo simulation, and creates charts. Your spreadsheet model may include various uncontrollable
uncertainties as input assumptions (e.g., demand for a new product, uncertain variable cost of
production, competitor reaction), and you can use simulation to determine the uncertainty associated
with the model's output (e.g., annual profit). RiskSim automates the simulation by trying hundreds of
what-ifs consistent with your assessment of the uncertainties.
2
(5) specify the model output cell and the number of what-if trials
(6) interpret RiskSim's histogram and cumulative distribution charts.
RiskSim adds nine random number generator functions to Excel. You can use these functions as
inputs to your model by typing in a worksheet cell or by using the Function Wizard. From the Insert
menu choose Function, or click the Function Wizard button. RiskSim's functions are listed in a User
Defined category. The nine functions are:
RANDBINOMIAL(trials,probability_s)
RANDCUMULATIVE(value_cumulative_table)
RANDDISCRETE(value_discrete_table)
RANDEXPONENTIAL(lambda)
RANDINTEGER(bottom,top)
RANDNORMAL(mean,standard_dev)
RANDPOISSON(mean)
RANDTRIANGULAR(minimum,most_likely,maximum)
RANDUNIFORM(minimum,maximum)
RiskSim's RAND... functions include extensive error checking of arguments. After verifying that the
functions are working properly, you may want to substitute RiskSim's FAST... functions which have
minimal error checking and therefore run faster. From the Edit menu choose Replace; in the Replace
dialog box, type =RAND in the "Find What" edit box, type =FAST in the "Replace with" edit box,
and click the Replace All button.
When you insert a RiskSim random number generator function in a worksheet cell, the function is
linked to the RiskSim XLA file. When you save the workbook, Excel saves the complete path to the
function in the RiskSim XLA file. When you open the workbook, Excel looks for the RiskSim XLA
file using the saved path. If Excel cannot find the RiskSim XLA file at the saved path location (e.g.,
if you deleted the RiskSim XLA file or if you opened the workbook on another computer where the
RiskSim XLA file isn't located at the same path), Excel displays a dialog box: "This document
contains links. Re-establish links?" Click No. The workbook will be opened, but any cell containing
a reference to a RiskSim function will display the #REF!, #NAME?, or other error code. To fix the
links, be sure that the RiskSim XLA file is open (e.g., File | Open | risk222p.xla), choose Edit | Links
| Change Source, and locate the RiskSim XLA file that is open.
3
Monte Carlo Simulation
After specifying random number generator functions as inputs to your model, from the Tools choose
Risk Simulation | One Output.
Optionally, select the "Output Label Cell" edit box, and point or type a reference to a cell containing
the name of the model output (for example, a cell whose contents is the text label "Net Profit").
Select the "Output Formula Cell" edit box, and point to a single cell on your worksheet or type a cell
reference. The output cell of your model must contain a formula that depends, usually indirectly, on
the model inputs determined by the random number generator functions.
Select the "Random Number Seed" edit box, and type a number between zero and one. (If you want
to change the seed without performing a simulation, enter zero in the "Number of iterations" edit
box.)
Select the "Number Of Trials" edit box, and type an integer value (for example, 100 or 500). This
value, sometimes called the sample size or number of iterations, specifies the number of times the
worksheet will be recalculated to determine output values of your model.
The "Random Number Seed" edit box on the RiskSim dialog box allows you to set the seed for
RiskSim's random number generator functions. These functions depend on RiskSim's own uniform
random number function that is completely independent of Excel's built-in RAND().
Random numbers generated by the computer are actually pseudo-random. The numbers appear to be
random, and they pass various statistical tests for randomness. But they are actually calculated by an
algorithm where each random number depends on the previous random number. Such an algorithm
generates a repeatable sequence. The seed specifies where the algorithm starts in the sequence.
A Monte Carlo simulation model usually has uncontrollable inputs (uncertain quantities using
random number generator functions), controllable inputs (decision variables that have fixed values
for a particular set of simulation iterations), and an output variable (a performance measure or
operating characteristic of the system).
4
For example, a simple queuing system model may have an uncertain arrival pattern, a controllable
number of servers, and total cost (waiting time plus server cost) as output. To evaluate a different
number of servers, you would specify the same seed before generating the uncertain arrivals. Then
the variation in total cost should depend on the different number of servers, not on the particular
sequence of random numbers that generates the arrivals.
One-Output Example
In this example the decision maker has described his subjective uncertainty using normal, triangular,
and discrete probability distributions.
A B C D E F G H
1 Software Decision Analysis
2
3 Unit Price $29 Price is controllable and constant.
4 Units Sold 739 Normal Mean = 700, StDev = 100
5 Unit Variable Cost $8.05 Triangular Min = $6, Mode = $8, Max = $11
6 Fixed Costs $12,000 Discrete Value Probability
7 $10,000 0.25
8 Net Cash Flow $3,485 $12,000 0.50
9 $15,000 0.25
A B
1 Software Decision Analysis
2
3 Unit Price $29
4 Units Sold =INT(RANDNORMAL(700,100))
5 Unit Variable Cost =RANDTRIANGULAR(6,8,11)
6 Fixed Costs =RANDDISCRETE(E7:F9)
7
8 Net Cash Flow =B4*(B3-B5)-B6
RiskSim Output
When you click the Simulate button, RiskSim creates a new worksheet in your Excel workbook
named "RiskSim Summary 1." A summary of your inputs and the output is shown in cells L1:R9
with the accompanying histogram and cumulative distribution charts.
5
L M N O P Q R
1 RiskSim - One Output - Summary Mean $2,454
2 Date (current date) St. Dev. $2,794
3 Time (current time) Mean St. Error $125
4 Workbook risksamp.xls Minimum -$5,455
5 Worksheet Simulation First Quartile $536
6 Output Cell $B$8 Median $2,458
7 Output Label Net Cash Flow Third Quartile $4,416
8 Seed 0.5 Maximum $10,236
9 Trials 500 Skewness 0.0028
10
11
RiskSim Histogram, (current date), (current time)
12
13
14 140
15 120
16
17 100
18
Frequency
80
19
20 60
21
40
22
23 20
24
25 0
26 -$6,000 -$2,000 $2,000 $6,000 $10,000
27 Net Cash Flow, Upper Limit of Interval
28
29
30
RiskSim Cumulative Chart, (current date), (current time)
31
32
33 1.0
34 0.9
35 0.8
Cumulative Probability
36 0.7
37 0.6
38 0.5
39 0.4
40
0.3
41
0.2
42
43 0.1
44 0.0
45 -$6,000 -$4,000 -$2,000 $0 $2,000 $4,000 $6,000 $8,000 $10,000 $12,000
46 Net Cash Flow
47
6
The histogram is based on the frequency distribution in columns I:J. The cumulative distribution is
based on the sorted output values in column C and the cumulative probabilities in column D.
A B C D E F G H I J
1 Trial Net Cash Flow Sorted Cumulative Percent Percentile Upper Limit Frequency
2 1 $1,653 -$5,455 0.0010 0% -$5,455 -$6,000 0
3 2 $2,804 -$4,267 0.0030 5% -$1,996 -$4,000 3
4 3 $2,280 -$4,185 0.0050 10% -$1,132 -$2,000 22
5 4 $761 -$3,898 0.0070 15% -$637 $0 72
6 5 -$1,817 -$3,675 0.0090 20% $77 $2,000 122
7 6 -$692 -$3,582 0.0110 25% $536 $4,000 128
8 7 $623 -$3,569 0.0130 30% $923 $6,000 105
9 8 $5,575 -$3,562 0.0150 35% $1,331 $8,000 38
10 9 $1,389 -$3,547 0.0170 40% $1,823 $10,000 9
11 10 $445 -$3,275 0.0190 45% $2,063 $12,000 1
12 11 $2,573 -$3,207 0.0210 50% $2,458 0
13 12 $5,055 -$3,137 0.0230 55% $2,756
14 13 $1,430 -$3,135 0.0250 60% $3,138
15 14 $4,529 -$3,063 0.0270 65% $3,644
16 15 $701 -$3,036 0.0290 70% $4,104
17 16 -$903 -$3,008 0.0310 75% $4,416
18 17 $3,900 -$2,968 0.0330 80% $4,867
19 18 $7,282 -$2,950 0.0350 85% $5,412
20 19 $9,901 -$2,774 0.0370 90% $5,897
21 20 $285 -$2,649 0.0390 95% $7,109
22 21 $3,833 -$2,485 0.0410 100% $10,236
23 22 $4,369 -$2,370 0.0430
24 23 $1,991 -$2,319 0.0450
25 24 -$11 -$2,219 0.0470
26 25 $1,100 -$2,195 0.0490
27 26 -$1,100 -$1,986 0.0510
28 27 -$5,455 -$1,969 0.0530
The cumulative probabilities start at 1/(2*N), where N is the number of trials, and increase by 1/N.
The rationale is that the lowest ranked output value of the sampled values is an estimate of the
population's values in the range from 0 to 1/N, and the lowest ranked value is associated with the
median of that range.
Columns F:G show percentiles based on Excel's PERCENTILE worksheet function. Refer to Excel's
online help for the interpolation method used by the PERCENTILE function.
The summary measures in columns Q:R are also based on Excel worksheet functions: AVERAGE,
STDEV, QUARTILE, and SKEW.
7
RandBinomial
Returns a random value from a binomial distribution. The binomial distribution can model a process
with a fixed number of trials where the outcome of each trial is a success or failure, the trials are
independent, and the probability of success is constant. RANDBINOMIAL counts the total number
of successes for the specified number of trials. If n is the number of trials, the possible values for
RANDBINOMIAL are the non-negative integers 0,1,...,n.
RANDBINOMIAL Remarks
RANDBINOMIAL Example
A salesperson makes ten unsolicited calls per day, where the probability of making a sale on each
call is 30 percent. The uncertain total number of sales in one day is =RANDBINOMIAL(10,0.3)
8
RandCumulative
Returns a random value from a piecewise-linear cumulative distribution. This function can model a
continuous-valued uncertain quantity, X, by specifying points on its cumulative distribution. Each
point is specified by a possible value, x, and a corresponding left-tail cumulative probability,
P(X<=x). Random values are based on linear interpolation between the specified points.
RANDCUMULATIVE Remarks
RANDCUMULATIVE Example
1 1000 0.0
Cumulative Probability, P(X<=x
4 7000 0.9
0.4
5 9000 1.0
0.2
9
RandDiscrete
Returns a random value from a discrete probability distribution. This function can model a discrete-
valued uncertain quantity, X, by specifying its probability mass function. The function is specified
by each possible discrete value, x, and its corresponding probability, P(X=x).
RANDDISCRETE Remarks
RANDDISCRETE Example
A B 1
1 3000 0.3
Cumulative Probability, P(X<=x
0
0 1000 2000 3000 4000 5000 6000 7000
Market Demand, x, in units
10
RandExponential
Returns a random value from an exponential distribution. This function can model the uncertain time
interval between successive arrivals at a queuing system or the uncertain time required to serve a
customer.
RANDEXPONENTIAL Remarks
RANDEXPONENTIAL Examples
Cars arrive at a toll plaza with a mean rate of 3 cars per minute. The uncertain time between
successive arrivals, measured in minutes, is =RANDEXPONENTIAL(3). The average value returned
by repeated recalculation of RANDEXPONENTIAL(3) is 0.333.
A bank teller requires an average of two minutes to serve a customer. The uncertain customer service
time, measured in minutes, is =RANDEXPONENTIAL(0.5). The average value returned by repeated
recalculation of RANDEXPONENTIAL(0.5) is 2.
11
RandInteger
Returns a uniformly distributed random integer between two integers you specify.
RANDINTEGER Remarks
RANDINTEGER Example
The number of orders a particular customer will place next year is between 7 and 11, with no number
more likely than the others. The uncertain number of orders is =RANDINTEGER(7,11).
12
RandNormal
Returns a random value from a normal distribution. This function can model a variety of phenomena
where the values follow the familiar bell-shaped curve, and it has wide application in statistical
quality control and statistical sampling.
RANDNORMAL Remarks
RANDNORMAL Example
The total market for a product is approximately normally distributed with mean 60,000 units and
standard deviation 5,000 units. The uncertain total market is =RANDNORMAL(60000,5000).
13
RandPoisson
Returns a random value from a Poisson distribution. This function can model the uncertain number
of occurrences during a specified time interval, for example, the number of arrivals at a service
facility during an hour. The possible values of RANDPOISSON are the non-negative integers, 0, 1,
2, ... .
RANDPOISSON Remarks
RANDPOISSON Examples
Cars arrive at a toll plaza with a mean rate of 3 cars per minute. The uncertain number of arrivals in a
minute is =RANDPOISSON(3). The average value returned by repeated recalculation of
RANDPOISSON(3) is 3.
A bank teller requires an average of two minutes to serve a customer. The uncertain number of
customers served in a minute is =RANDPOISSON(0.5). The average value returned by repeated
recalculation of RANDPOISSON(0.5) is 0.5.
14
RandTriangular
Returns a random value from a triangular probability density function. This function can model an
uncertain quantity where the most likely value (mode) has the largest probability of occurrence, the
minimum and maximum possible values have essentially zero probability of occurrence, and the
probability density function is linear between the minimum and the mode and between the mode and
the maximum. This function can also model a ramp density function where the minimum equals the
mode or the mode equals the maximum.
RANDTRIANGULAR Remarks
RANDTRIANGULAR Example
hours. 0.2
0.1
0
0 2 4 6 8 10
Task Time, x, in hours
=RANDTRIANGULAR(4,6,10). 0.6
0.4
0.2
0
0 2 4 6 8 10
Task Time, x, in hours
15
RandUniform
Returns a uniformly distributed random value between two values you specify. As a special case,
RANDUNIFORM(0,1) is the same as Excel's built-in RAND() function.
RANDUNIFORM Remarks
RANDUNIFORM Example
A corporate planner thinks that the company's product will garner between 10% and 15% of the total
market, with all possible percentages equally likely in the specified range. The uncertain market
proportion is =RANDUNIFORM(0.10,0.15).
16
Technical Details
RiskSim's random number generator functions are based on a uniformly distributed random number
function called RandSeed which is not directly accessible by the user. Each value of RandSeed is
calculated by multiplying 9821 times the previous value of RandSeed, adding 0.211327, and taking
the fractional part. This algorithm is the same as the one used by Excel 4's built-in RAND() function.
When RiskSim starts, the previous random number for RandSeed is set to 0.5. The first time a
random number is calculated, the resulting value is 0.711327. Unlike Excel's RAND() function, you
can use RiskSim at any time to specify the previous random number (the seed) for the sequence of
random numbers generated by the RiskSim functions.
In the Risk Simulation dialog box, the "Random number seed" edit box changes the seed only for the
RiskSim functions; it does not have any effect on Excel's built-in RAND() function.
Each of RiskSim's random number generator functions use RandSeed as a building block.
17
RiskSim includes a FAST... version of each of the nine functions, e.g., FASTBINOMIAL,
FASTCUMULATIVE, etc. The FAST... functions are identical to the RAND... functions except
there is no error checking of arguments.
18