0% found this document useful (0 votes)
126 views8 pages

3 Spreadsheet Simulation Overview

Spreadsheet simulation uses a spreadsheet as a platform for representing simulation models and performing simulation experiments. It allows the developer to organize computations and outputs in an intuitive manner using the table structure of a spreadsheet. The document provides an example of simulating coin tosses in a spreadsheet and using the SIMTOOLS add-in to model uncertain inputs like rates of return as probability distributions. It demonstrates how to set up and run a simulation of total assets over time with stochastic inputs and outputs.

Uploaded by

Abdu Abdoulaye
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
126 views8 pages

3 Spreadsheet Simulation Overview

Spreadsheet simulation uses a spreadsheet as a platform for representing simulation models and performing simulation experiments. It allows the developer to organize computations and outputs in an intuitive manner using the table structure of a spreadsheet. The document provides an example of simulating coin tosses in a spreadsheet and using the SIMTOOLS add-in to model uncertain inputs like rates of return as probability distributions. It demonstrates how to set up and run a simulation of total assets over time with stochastic inputs and outputs.

Uploaded by

Abdu Abdoulaye
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

?

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.

We focus on static simulation using a spreadsheet


2

1
Toss coins in a spreadsheet Total number of coins = 100

Index of coins Outcome X Total number of heads obtained


1 =IF(RAND()<0.5, 1, 0) 1: Head =SUM(B4:B103)
2 =IF(RAND()<0.5, 1, 0) 0: Tail
3 0 Sample mean of X
4 0 =AVERAGE(B4:B103)
5 0
6 0 Sample Variance
7 0 =VAR(B4:B103)
8 0
9 0 Maximum of B4 and B5
10 0 =MAX(B4, B5)
11 1
12 1 Display "B4" if B4 > B5
13 0 Display "B5" otherwise
14 1 =IF(B4>B5, "B4","B5")

Toss coins in a spreadsheet Total number of coins = 100

Index of coins Outcome X Total number of heads obtained


1 1 1: Head 55
2 1 0: Tail
3 1 Sample mean of X
4 0 0.55
5 1
6 0 Sample Variance
7 1 0.25
8 1
9 1 Maximum of B4 and B5
10 0 1
11 0
12 0 Display "B4" if B4 > B5
13 1 Display "B5" otherwise
14 0 B5

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

Assets Value Now Rate of Return Value Next Year


Bonds $5,000.00 ? RV ? RV
Stocks $10,000.00 ? RV ? RV
Cash $2,000.00 ? RV ? RV

Total Assets ? RV

Inputs to the model: blue columns


Stochastic inputs: Rate of Return
Outputs from the model: purple columns
Stochastic output: Total assets
Intermediate computation
7

Modeling the Inputs


The rate of return on each of my investments is uncertain, so I
model each rate with a probability distribution.
Using SIMTOOLS to model the stochastic inputs.
bonds: TRIANINV( RAND( ), 0.04, 0.06, 0.08 )
stocks: NORMINV( RAND( ), 0.1, 0.1 )
cash: 0.03 + RAND( ) *0.02

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

Excel function for


calculating percentiles:
(25th percentile)
=PERCENTILE(D8:D2007, 0.25)

11

Example: My Finances (contd)


What is the expected value of my total assets in the next year?
Deterministic approximation: using the expected value of the
random inputs to estimate the total assets.
Method of simulation
9 Sampling by running independent simulation experiments
9 Estimate the parameter of interest based on simulation data

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.

What ifquestions What if the interest rate changes?


What if I put more money in stocks?14

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

Optimization via Simulation


How should I invest the money among Bonds, Stocks, and
Cash?
Objective: maximize the expected value of the total assets in a
year; minimize the risk of investment.

15

You might also like