3 Spreadsheet Simulation Overview
3 Spreadsheet Simulation Overview
Spreadsheet Simulation
Overview
IENG 455
Feng Yang
West Virginia University
1
Spreadsheet Simulation
Spreadsheet simulation refers to the use of a spreadsheet as a
platform for representing simulation models and performing
simulation experiments.
Why is spreadsheet an attractive platform for simulation?
9Spreadsheets are ubiquitous
9Provides a large number of functions to do mathematical,
statistical, and other calculations.
9The table structure of spreadsheet allows the developer to
organize the computations and outputs in a natural and
intuitive manner.
1
Toss coins in a spreadsheet Total number of coins = 100
2
SIMTOOLS and Excel
SIMTOOLS is an add-in for Microsoft Excel.
SIMTOOLS adds risk analysis without changing
normal Excel functionality.
SIMTOOLS provides additional functions and
procedures for spreadsheet simulation.
Users guide of SIMTOOLS is included in:
SIMTOOLS User Manual
You interact with the SIMTOOLS menu:
Tools SimTools
5
SIMTOOLS Functions
SIMTOOLS functions are used just as Excel functions are used.
In a spreadsheet cell, type =MIN(3,5)
= SimtoolsFunction(Parameters)
Most functions specify probability distributions from which the
value of the cell should be sampled.
e.g.,
Generate a random number pdf:
that follows a triangle x
distribution: 0 1 2
= TRIANINV( RAND( ), 0, 1, 2 )
RAND( ) returns a uniformly distributed random number over
the interval [ 0, 1 ].
3
Example: My Finances
My Money
Total Assets ? RV
pdf:
x
0 0.03 0.05
To create random variables with a Uniform distribution over
the interval [ a, b ] : a + RAND( )* (b a)
8
4
1 B C D E
2 My Money
3
4 Deterministic Approx. Expected Rate of Return
5 Assets Value Now Rate of Return Value Next Year
6 Bonds $5,000.00 6% $5,300.00
7 Stocks $10,000.00 10% $11,000.00
8 Cash $2,000.00 4% $2,080.00
9
10 Total Assets $18,380.00
11
12
13
14 Run Simulation Random Rate of Return
15 Assets Value Now Rate of Return Value Next Year
16 Bonds $5,000.00 =TRIANINV( RAND( ), 0.04, 0.06, 0.08 ) =C16*(1+D16)
17 Stocks $10,000.00 =NORMINV( RAND( ), 0.1, 0.1 ) =C17*(1+D17)
18 Cash $2,000.00 =RAND( ) *0.02+ 0.03 =C18*(1+D18)
19
20 Total Assets =SUM(E15:E17)
9
10
5
Total assets X is a random output
Histogram based on 2000 observations of total assets X
Percentiles
0.25 17730.5299
0.5 18411.351
0.75 19073.90163
11
Conclusions
The premise of risk analysis is that more than the mean
(long-run average) matters.
Even when all we want is the mean, we cant get it by plugging
in averages of all the uncertain stuff.
12
6
Simulation with SIMTOOLS
Recalc key [F9]: press [F9] to recalculate the spreadsheet
(generate a different random scenario).
Perform n simulation runs to obtain a sample of size n for the
random output.
Using the SimTools procedure Simulation Table to tabulate
outputs from repeated recalculations of a simulation model.
Tools SimTools Simulation Table
Make a simulation table
The outputs that we want to store in the table must be listed
together in a single row. This model-output row must also
have at least on blank cell to its left, and beneath the model-
output row there must be many rows of blank cells where the
simulation will be written.
13
Method of Simulation
The simulation consists of:
1. Generate random variates to represent stochastic inputs
2. Combining all the inputs according to the formulas or rules
to produce an observation for the random output.
3. Repeat Step 1&2 for a specified number of times (run a
specified number of replications) to produce a random
sample consisting of i.i.d observations.
4. Use standard statistical and graphical methods to show the
distribution of the data and estimate parameters of this
distribution such as the mean, variance, and percentiles.
To evaluate the risk of uncertainty we can use a spreadsheet
to simulate the possible futures we might see.
7
Modeling Dependence
I just remembered that stock and bond returns are dependent
(when one is up, the other tends to be down)
I need to Correlate them when modeling the input.
I choose a correlation of -0.6
15