Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Monte Carlo Risksim

Download as pdf or txt
Download as pdf or txt
You are on page 1of 18

Monte Carlo Simulation Using RiskSim

Add-In for Microsoft Excel

Contents

How to Install RiskSim ..................................................2


How to Uninstall or Delete RiskSim ..............................2
Overview.........................................................................2
Using RiskSim Functions ...............................................3
Excel Error Message.......................................................3
Monte Carlo Simulation..................................................4
Random Number Seed ....................................................4
One-Output Example ......................................................5
RiskSim Output...............................................................6
RandBinomial .................................................................8
RandCumulative .............................................................9
RandDiscrete.................................................................10
RandExponential...........................................................11
RandInteger...................................................................12
RandNormal..................................................................13
RandPoisson .................................................................14
RandTriangular .............................................................15
RandUniform ................................................................16
Technical Details ..........................................................17
How to Install RiskSim

Here are three ways to install RiskSim:

(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.

How to Uninstall or Delete RiskSim

(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.

To use RiskSim, you

(1) create a spreadsheet model


(2) optionally use SensIt to identify critical inputs
(3) enter one of RiskSim's random number generator functions in each input cell of your model
(4) choose Tools | Risk Simulation from Excel's menu

2
(5) specify the model output cell and the number of what-if trials
(6) interpret RiskSim's histogram and cumulative distribution charts.

RiskSim facilitates Monte Carlo simulation by providing:

Nine random number generator functions


Ability to set the seed for random number generation
Automatic repeated sampling for simulation
Frequency distribution of simulation results
Histogram and cumulative distribution charts

Using RiskSim Functions

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.

Excel Error Message

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.

Random Number Seed

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.

Column B contains the original sampled output values.

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 Syntax: RANDBINOMIAL(trials,probability_s)

Trials (often denoted n) is the number of independent trials.


Probability_s (often denoted p) is the probability of success on each trial.

RANDBINOMIAL Remarks

Returns #N/A if there are too few or too many arguments.


Returns #NAME! if an argument is text and the name is undefined.
Returns #NUM! if trials is non-integer or less than one, or probability_s is less than zero or more
than one.
Returns #VALUE! if an argument is a defined name of a cell and the cell is blank or contains text.

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)

RANDBINOMIAL Related Function

FASTBINOMIAL: Same as RANDBINOMIAL without any error checking of the arguments.


CRITBINOM(trials,probability_s,RAND()): Excel's inverse of the cumulative binomial, or
CRITBINOM(trials,probability_s,RANDUNIFORM(0,1)) to use the RiskSim Seed feature.

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 Syntax: RANDCUMULATIVE(value_cumulative_table)

Value_cumulative_table must be a reference, or the defined name of a reference, for a two-column


range, with values in the left column and corresponding cumulative probabilities in the right column.

RANDCUMULATIVE Remarks

Returns #N/A if there are too few or too many arguments.


Returns #NAME! if the argument is text and the name is undefined.
Returns #NUM! if the first (top) cumulative probability is not zero, if the last (bottom) cumulative
probability is not one, or if the values or cumulative probabilities are not in ascending order.
Returns #REF! if the number of columns in the table reference is not two.
Returns #VALUE! if the argument is not a reference, if the argument is a defined name but not for a
reference, or if any cell of the table contains text or is blank.

RANDCUMULATIVE Example

A corporate planner thinks that 0.0005

minimum possible market demand is


1000 units, median is 5000, and 0.0004
Probability Density, f(x)

maximum possible is 9000. Also, 0.0003

there is a ten percent chance that


0.0002
demand will be less than 4000 and a
ten percent chance it will exceed 0.0001

7000. The values, x, and cumulative 0


probabilities, P(X<=x), are entered 0 2000 4000 6000 8000 10000
Market Demand, x, in units
into spreadsheet cells A1:B5.
A B 1

1 1000 0.0
Cumulative Probability, P(X<=x

2 4000 0.1 0.8

3 5000 0.5 0.6

4 7000 0.9
0.4
5 9000 1.0
0.2

The function is entered into another 0


cell: =RANDCUMULATIVE(A1:B5) 0 2000 4000 6000 8000 10000
Market Demand, x, in units

RANDCUMULATIVE Related Function

FASTCUMULATIVE: Same as RANDCUMULATIVE without any error checking of the


arguments.

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 Syntax: RANDDISCRETE(value_discrete_table)

Value_discrete_table must be a reference, or the defined name of a reference, for a two-column


range, with values in the left column and corresponding probability mass in the right column.

RANDDISCRETE Remarks

Returns #N/A if there are too few or too many arguments.


Returns #NAME! if the argument is text and the name is undefined.
Returns #NUM! if a probability is negative or if the probabilities do not sum to one.
Returns #REF! if the number of columns in the table reference is not two.
Returns #VALUE! if the argument is not a reference, if the argument is a defined name but not for a
reference, or if any cell of the table contains text or is blank.

RANDDISCRETE Example

A corporate planner thinks that 0.7

uncertain market demand, X, can be 0.6

approximated by three possible values 0.5

and their associated probabilities: 0.4

P(X=3000) = 0.3, P(X=4000) = 0.6, 0.3


and P(X=5000) = 0.1. The values and 0.2
probabilities are entered into 0.1
spreadsheet cells A1:B3. 0
0 1000 2000 3000 4000 5000 6000 7000
Ma rke t De ma nd, x, in units

A B 1

1 3000 0.3
Cumulative Probability, P(X<=x

2 4000 0.6 0.8

3 5000 0.1 0.6

The function is entered into another


0.4
cell: =RANDDISCRETE(A1:B3)
0.2

0
0 1000 2000 3000 4000 5000 6000 7000
Market Demand, x, in units

RANDDISCRETE Related Function

FASTDISCRETE: Same as RANDDISCRETE without any error checking of the arguments.

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 Syntax: RANDEXPONENTIAL(lambda)

Lambda is the mean number of occurrences per unit of time.

RANDEXPONENTIAL Remarks

Returns #N/A if there are too few or too many arguments.


Returns #NAME! if the argument is text and the name is undefined.
Returns #NUM! if lambda is negative or zero.
Returns #VALUE! if the argument is a defined name of a cell and the cell is blank or contains text.

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.

RANDEXPONENTIAL Related Functions

FASTEXPONENTIAL: Same as RANDEXPONENTIAL without any error checking of the


arguments.
−LN(RAND())/lambda: Excel's inverse of the exponential, or
−LN(RANDUNIFORM(0,1))/lambda to use the RiskSim Seed feature.
RANDPOISSON: Counts number of occurrences for a Poisson process.

11
RandInteger

Returns a uniformly distributed random integer between two integers you specify.

RANDINTEGER Syntax: RANDINTEGER(bottom,top)

Bottom is the smallest integer RANDINTEGER will return.


Top is the largest integer RANDINTEGER will return.

RANDINTEGER Remarks

Returns #N/A if there are too few or too many arguments.


Returns #NAME! if an argument is text and the name is undefined.
Returns #NUM! if top is less than or equal to bottom.
Returns #VALUE! if bottom or top is not an integer or if an argument is a defined name of a cell and
the cell is blank or contains text.

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).

RANDINTEGER Related Function

FASTINTEGER: Same as RANDINTEGER without any error checking of the arguments.


RANDBETWEEN(bottom,top): Excel’s function for uniformly distributed integers, without
RiskSim’s capability of setting the seed.

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 Syntax: RANDNORMAL(mean,standard_dev)

Mean is the arithmetic mean of the normal distribution.


Standard_dev is the standard deviation of the normal distribution.

RANDNORMAL Remarks

Returns #N/A if there are too few or too many arguments.


Returns #NAME! if an argument is text and the name is undefined.
Returns #NUM! if standard_dev is negative.
Returns #VALUE! if an argument is a defined name of a cell and the cell is blank or contains text.

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).

RANDNORMAL Related Function

FASTNORMAL: Same as RANDNORMAL without any error checking of the arguments.


NORMINV(RAND(),mean,standard_dev): Excel's inverse of the normal, or
NORMINV(RANDUNIFORM(0,1),mean,standard_dev) to use the RiskSim Seed feature.

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 Syntax: RANDPOISSON(mean)

Mean is the mean number of occurrences per unit of time.

RANDPOISSON Remarks

Returns #N/A if there are too few or too many arguments.


Returns #NAME! if the argument is text and the name is undefined.
Returns #NUM! if mean is negative or zero.
Returns #VALUE! if mean is a defined name of a cell and the cell is blank or contains text.

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.

RANDPOISSON Related Functions

FASTPOISSON: Same as RANDPOISSON without any error checking of the arguments.

RANDEXPONENTIAL: Describes time between occurrences for a Poisson process.

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 Syntax: RANDTRIANGULAR(minimum,most_likely,maximum)

Minimum is the smallest value RANDTRIANGULAR will return.


Most_likely is the most likely value RANDTRIANGULAR will return.
Maximum is the largest value RANDTRIANGULAR will return.

RANDTRIANGULAR Remarks

Returns #N/A if there are too few or too many arguments.


Returns #NAME! if an argument is text and the name is undefined.
Returns #NUM! if minimum is greater than or equal to maximum, if most_likely is less than
minimum, or if most_likely is greater than maximum.
Returns #VALUE! if an argument is a defined name of a cell and the cell is blank or contains text.

RANDTRIANGULAR Example

The minimum time required to 0.6

complete a particular task that is part 0.5


of a large project is 4 hours, the most
Probability Density, f(x)

likely time required is 6 hours, and 0.4

the maximum time required is 10 0.3

hours. 0.2

0.1

0
0 2 4 6 8 10
Task Time, x, in hours

The function returning the uncertain 1

time required for the task is entered


Cumulative Probability, P(X<=x

into a cell: 0.8

=RANDTRIANGULAR(4,6,10). 0.6

0.4

0.2

0
0 2 4 6 8 10
Task Time, x, in hours

RANDTRIANGULAR Related Function

FASTTRIANGULAR: Same as RANDTRIANGULAR without any error checking of arguments.

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 Syntax: RANDUNIFORM(minimum,maximum)

Minimum is the smallest value RANDUNIFORM will return.


Maximum is the largest value RANDUNIFORM will return.

RANDUNIFORM Remarks

Returns #N/A if there are too few or too many arguments.


Returns #NAME! if an argument is text and the name is undefined.
Returns #NUM! if minimum is greater than or equal to maximum.
Returns #VALUE! if an argument is a defined name of a cell and the cell is blank or contains text.

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).

RANDUNIFORM Related Function

FASTUNIFORM: Same as RANDUNIFORM without any error checking of the arguments.

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.

RANDBINOMIAL(trials,probability_s) uses RandSeed as the cumulative probability in Excel's


built-in CRITBINOM function.

RANDCUMULATIVE(value_cumulative_table) uses the value of RandSeed, R, searches to find the


adjacent cumulative probabilities that bracket R, and interpolates on the linear segment of the
cumulative distribution to find the corresponding value.

RANDDISCRETE(value_discrete_table) compares RandSeed with summed probabilities of the


input table until the sum exceeds the RandSeed value, and then returns the previous value from the
input table.

RANDEXPONENTIAL(lambda) uses the value of RandSeed, R, as follows. If the exponential


density function is f(t) = lambda*EXP(-lambda*t), the cumulative is P(T<=t) = 1 - EXP(-lambda*t).
Associating R with P(T<=t), the inverse cumulative is t = -LN(1-R)/lambda. Since R and 1-R are
both uniformly distributed between 0 and 1, RiskSim uses -LN(R)/lambda for the returned value.

RANDINTEGER(bottom,top) returns bottom + INT(RandSeed*(top-bottom+1)).

RANDNORMAL(mean,standard_dev) uses RandSeed as the cumulative probability in Excel's built-


in NORMINV function.

RANDPOISSON(mean) compares RandSeed with cumulative probabilities of Excel's built-in


POISSON function until the probability exceeds the RandSeed value, and then returns the previous
value.

RANDTRIANGULAR(minimum,most_likely,maximum) uses RandSeed once. The triangular


density function has two linear segments, so the cumulative distribution has two quadratic segments.
The returned value is determined by interpolation on the appropriate quadratic segment.

RANDUNIFORM(minimum,maximum) returns minimum + RandSeed*(maximum-minimum).


RANDUNIFORM(0,1) is equivalent to Excel's built-in RAND() function.

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.

Copyright  2006 by Michael R. Middleton

Decision Support Services


2105 Buchanan Street, #1
San Francisco, CA 94115
Email: support@treeplan.com
Web Site: http://www.treeplan.com

18

You might also like