You are on page 1of 43

http://www.solver.com/risk-analysis/tutorial.

htm
Risk Analysis - Overview
Risk analysis is the systematic study of uncertainties and risks we encounter in
business, engineering, public policy, and many other areas. Risk analysts seek to
identify the risks faced by an institution or business unit, understand how and when
they arise, and estimate the impact (financial or otherwise) of adverse outcomes. Risk
managers start with risk analysis, then seek to take actions that will mitigate or hedge
these risks.
ome institutions, such as banks and investment management firms, are in the
business of taking risks every day. Risk analysis and management is clearly crucial
for these institutions. !ne of the roles of risk management in these firms is to
"uantify the financial risks involved in each investment, trading, or other business
activity, and allocate a risk budget across these activities. #anks in particular are
re"uired by their regulators to identify and "uantify their risks, often computing
measures such as \$alue at Risk (\$aR), and ensure that they have ade"uate capital to
maintain solvency should the worst (or near-worst) outcomes occur.
• %uantitative Risk &nalysis
• 'odels and imulation
• 'onte (arlo imulation
Quantitative Risk Analysis
%uantitative risk analysis is the practice of creating a mathematical model of a pro)ect
or process that e*plicitly includes uncertain parameters that we cannot control, and
also decision variables or parameters that we can control. & "uantitative risk model
calculates the impact of the uncertain parameters and the decisions we make on
outcomes that we care about -- such as profit and loss, investment returns,
environmental conse"uences, and the like. uch a model can help business decision
makers and public policy makers understand the impact of uncertainty and the
conse"uences of different decisions. (onsult our risk analysis tutorial for more
Models and Simulation
!ne way to learn how to deal with uncertainty is to perform an e*periment. #ut
often, it is too dangerous or e*pensive to perform an e*periment in the +real world+ --
so we resort to a model, such as a scale model of an airplane in a wind tunnel. ,ith a
model, we can simulate what would happen in the real world, and perform many
e*periments -- for e*ample, sub)ecting our model airplane to various air currents and
forces -- and learn how it behaves. ,e can introduce uncertainty into our e*periments
using devices such as a coin toss, dice roll, or roulette wheel. & single e*periment
that involves a coin toss may not tell us very much, but if we perform a simulation
that consists of many e*periments or trials, and collect statistics about the results, we
can learn "uite a lot.
-f we have the skills and software tools needed to create a mathematical model of a
pro)ect or process on a computer, we can perform a simulation with many trials in a
very short time, and at very low cost. ,ith such advantages over e*periments in the
real world, it.s no wonder that computer-based simulation has become so popular. /or
business models, 'icrosoft 0*cel is an ideal tool for creating such a model -- and
simulation software such as /rontline ystems. Risk olver can be used to get
ma*imum insight from the model.
Monte Carlo Simulation
'onte (arlo simulation -- named after the city in 'onaco famed for its casinos and
games of chance -- is a powerful mathematical method for conducting "uantitative
risk analysis. 'onte (arlo methods rely on random sampling -- the computer-based
e"uivalent of a coin toss, dice roll, or roulette wheel. 1he numbers from random
sampling are +plugged into+ a mathematical model and used to calculate outcomes of
interest. 1his process is repeated many -- typically thousands of -- times. ,ith the
aid of software, we can obtain statistics and view charts and graphs of the results. 1o
'onte (arlo simulation is especially helpful when there are several different sources
of uncertainty that interact to produce an outcome. /or e*ample, if we.re dealing with
uncertain market demand, competitors. pricing, and variable production and raw
materials costs at the same time, it can be very difficult to estimate the impacts of
these factors -- in combination -- on 2et 3rofit. 'onte (arlo simulation can "uickly
analy4e thousands of .what-if. scenarios, often yielding surprising insights into what
can go right, what can go wrong, and what we can do about it.
• ,hat is Risk, and ,hy 5o ,e (are6
• ,hat are ources of 7ncertainty6
• 8ow are 7ncertainty and Risk 5ifferent6
• 8ow (an ,e #est 5eal with Risk6
Risk Analysis - Tutorial
What is Risk?
7ncertainty, which is constantly present in our daily lives, fre"uently impacts our
decisions and actions. ,hen we talk about risk, we normally mean the chance that
some undesirable impact will occur. 8ence, we normally seek to avoid or minimi4e
risk. -f there is a chance of rain, and we don.t want to get wet, we may choose to stay
indoors -- avoiding that risk -- or we may take an umbrella to minimi4e the impact of
rain upon us.
7ncertainty can impact our decisions and actions in desirable as well as undesirable
ways. -f we own shares of stock, the future price is uncertain -- it may go higher,
which is desirable, or it may go lower, which is undesirable. ,hen contemplating
large payoffs or penalties, most people are risk averse. /or e*ample, if we can choose
between a coin toss that gains 9:; or breaks even, and a coin toss that gains 9<:; or
loses 9<;;, most people would choose the first coin toss, even though the average or
.e*pected. outcome of both tosses is 9=:. 8ence, in risk analysis we usually focus on
what can go wrong -- the outcomes that represent loss or damage -- although an
effective analysis will also help us understand what can go right as well.
What are Sources of ncertainty?
ncertainty can arise in several ways!

• -f the "uantity we.d like to know is a competing firm.s planned product price,
uncertainty arises from our lack of knowledge: 1he price may be well known
to that firm.s employees, but it.s unknown to us.
• -f the "uantity is market demand for products like ours, uncertainty arises from
the comple*ity of the process: 5emand depends on economic factors,
fashions and preferences, and our and other firms. actions -- and even if we
knew all of these, we couldn.t fully calculate their net impact on final demand.
• -f the "uantity is a material thickness in nanometers, uncertainty may arise
from limits on our ability to measure this physical "uantity. ,e may also have
limits on our ability to control fabrication of the material.
• 'any processes that we want to model -- from the failure rate of an electronic
component to the behavior of a macromolecule -- have inherent randomness
for all intents and purposes.
7ncertainty that is inherent in nature is sometimes called irreducible uncertainty. >ou
may be able to reduce the effect of the random variation on your model, or reduce
your model.s sensitivity to this variation, but it will always be there. -n other
situations you may be dealing with reducible uncertainty -- through market research,
physical tests, better calibration, or other means you may be able to reduce the
uncertainty itself.
"ow are ncertainty and Risk #ifferent?
7ncertainty is normally an intrinsic feature of some part of nature -- it is the same for
all observers. #ut risk is specific to a person or company -- it is not the same for all
observers. 1he possibility of rain tomorrow is uncertain for everyone? but the risk of
getting wet is specific to me, if (i) - intend to go outdoors and (ii) - view getting wet
as undesirable. 1he possibility that stock & will decline in price tomorrow is an
uncertainty for both you and me? but if you own the stock long and - do not, it is a risk
only for you. -f - have sold the stock short, a decline in price is a desirable outcome
for me.
'any, though certainly not all, risks involve choices. #y taking some action, we may
deliberately e*pose ourselves to risk -- normally because we e*pect a gain that more
than compensates us for bearing the risk. -f you and - come to a bridge across a
canyon that we want to cross, and we notice signs of weakness in its structure, there is
uncertainty about whether the bridge can hold our weight, independent of our actions.
-f - choose to walk across the bridge to reach the other side, and you choose to stay
where you are, - will bear the risk that the bridge will not hold my weight, but you
will not. 'ost business and investment decisions are choices that involve +taking a
calculated risk+ -- and risk analysis can give us better ways to make the calculation.
"ow Can We \$est #eal with Risk?
-f the stakes are high enough, we can and should deal with risk e*plicitly, with the aid
of a "uantitative model. &s humans, we have heuristics or +rules of thumb+ for
dealing with risk, but these don.t serve us very well in many business and public
policy situations. -n fact, much research shows that we have cognitive biases, such as
over-weighting the most recent adverse event and pro)ecting current good or bad
outcomes too far into the future, that work against our desire to make the best
decisions. %uantitative risk analysis can help us escape these biases, and make better
decisions.
-t helps to recogni4e up front that, when uncertainty is a large factor, the best decision
does not always lead to the best outcome. 1he +luck of the draw+ may still go against
us. Risk analysis can help us analy4e, document, and communicate to senior decision
makers and stakeholders the e*tent of uncertainty, the limits of our knowledge, and
the reasons for taking a course of action.
Risk Analysis - The %rocess

1he process of risk analysis includes identifying and "uantifying uncertainties,
estimating their impact on outcomes that we care about, building a risk analysis model
that e*presses these elements in "uantitative form, e*ploring the model through
simulation and sensitivity analysis, and making risk management decisions that can
help us avoid, mitigate, or otherwise deal with risk.
• -dentify and %uantify 7ncertainty
• (ompute the -mpact of 7ncertainty
• (omplete a Risk &nalysis 'odel
• 0*plore the 'odel with imulation
• &naly4e the 'odel Results
• 'ake 5ecisions to #etter 'anage Risk
&dentify and Quantify ncertainty
-n risk analysis, our goal is to identify each important source of uncertainty, and
"uantify its magnitude as well as we can. /or e*ample, we may not know our
competitor.s e*act price, but we can place bounds on it, based on known production
and marketing costs. ,hile we can.t predict the e*act number of people shopping at a
store each day, we can e*amine past data for the fre"uency of days when (say) <;, =;,
@;, ..., <;; people shopped, and use this to estimate a distribution of shoppers on
future days. 1his process of identifying and "uantifying uncertainties is a key step in
risk analysis.
Com'ute the &m'act of ncertainty
!ur ne*t step is to accurately estimate the impact of the uncertainties on the outcomes
we care about. /or e*ample, we may not be able to predict demand for our product
e*actly? but given a number for demand, since we know our costs and margins, we
can often calculate the impact on our 2et 3rofit. ,e may not know the e*act number
of shoppers on any future day? but given a number of shoppers, we can calculate how
many store salespeople we need to service them, and estimate the sales we.re likely to
generate. -n doing this, we build a model that allows us to compute +outputs+ --
outcomes such as 2et 3rofit -- for any given +inputs+.
Com'lete a Risk Analysis Model
-f we can complete these steps, we.ll have a risk analysis model (or simply risk
model). 1he model has inputs which are uncertain -- these may be called uncertain
variables, random variables, assumptions, or simply inputs. /or any given set of input
values, the model calculates outputs -- outcomes such as 2et 3rofit.
7nlike other kinds of models, a risk analysis model re"uires us to think in ranges:
#ecause the inputs are uncertain and may take on many different values, the outputs
are also uncertain and may take on a range of values. -f management asks, +Aive me
a number for ne*t year.s sales+, a risk analyst must respond that a single number is not
going to be meaningful -- it will defeat the purpose of risk analysis.
()'lore the Model with Simulation
,e can use our risk model in several ways -- but one effective way is to e*plore the
possible outcomes using simulation. /or a model in 0*cel, we can use software, such
as /rontline.s Risk olver, to perform a 'onte (arlo simulation on our model.
imulation performs many (thousands of) e*periments or trials -- each one samples
possible values for the uncertain inputs, and calculates the corresponding output
values for that trial.
1he first run of a simulation model can often yield results that are surprising to the
modelers or to management -- especially when there are several different sources of
uncertainty that interact to produce an outcome. 0ven before an in-depth analysis of
the results, simply seeing the range of outcomes -- for e*ample, how low and how
high 2et 3rofit can be, given our model and sources of uncertainty -- can encourage a
re-thinking of the risks we face, and the actions we can take.
Analy*e the Model Results
#ecause a simulation yields many possible values for the outcomes we care about --
from 2et 3rofit to environmental impact -- some work is needed to analy4e the
results. -t is very useful to create charts to help us visuali4e the results -- such as
fre"uency histogram charts and cumulative fre"uency charts. ,e can summari4e the
range of outcomes using various kinds of statistics, such as the mean or median, the
standard deviation and variance, or the :th and B:th percentile or \$alue at Risk.
&nother powerful tool for assessing model results is sensitivity analysis, which can
help us identify the uncertain inputs with the biggest impact on our key outcomes.
/or e*ample, a tornado chart can give us a "uick visual summary of the uncertainties
with the greatest positive and negative impact on 2et 3rofit. 7sing software, we can
also run multiple simulations, with an input we choose taking a different value on
each simulation, and assess the results. &naly4ing the model can give us more
information, but also insight about our real-world problem.
Make #ecisions to \$etter Mana+e Risk
1he payoff comes when we use our risk analysis model and simulation results to
make choices or decisions, that may help us avoid or mitigate risk -- or perhaps earn
greater returns that help compensate us for taking these risks. ,e can also compare
the risk and return of different pro)ects or investments, and we can seek to diversify
our position so that no single risk can do too much harm. #y doing this, we can
practice risk management.
,hile we can.t avoid uncertainty and risk altogether, there are often many steps we
can take to better cope with risk. Risk analysis helps us determine the right steps to
take. !ur ne*t step in this 1utorial is to take a closer look at a risk analysis model.
Risk Analysis - Models
& risk analysis model could be a physical scale model, but it is most often a
mathematical model. 1he model can be created by writing code in a programming
language, statements in a simulation modeling language, or formulas in a 'icrosoft
0*cel spreadsheet. Regardless of how it is e*pressed, a risk analysis model will
include:

• 'odel inputs that are uncertain numbers -- we.ll call these uncertain variables
• -ntermediate calculations as re"uired
• 'odel outputs that depend on the inputs -- we.ll call these uncertain functions
-t is essential to reali4e that model outputs that depend on uncertain inputs are
uncertain themselves -- hence we talk about uncertain variables and uncertain
functions. 1o make use of a risk analysis model, we will test many different numeric
values for the uncertain variables, and we.ll obtain many different numeric values for
the uncertain functions. ,e.ll use statistics to analy4e and summari4e all the values
for the uncertain functions (and, if we wish, the uncertain variables).
• (reating the 'odel
• 'odel implification
• 2e*t: Running the 'odel
Creatin+ the Model
ince a risk analysis model will be sub)ect to intensive computations, you.ll generally
want to create the model using available risk analysis tools. &n 0*cel spreadsheet can
be a simple, yet powerful tool for creating your model -- especially when paired with
'onte (arlo simulation software such as Risk olver. -f your model is written in a
programming language, 'onte (arlo simulation toolkits like the one in /rontline.s
olver 3latform 5C provide powerful aids.
&n e*ample model in 0*cel might look like this, where cell #D contains a formula
E3si1riangular(0B,AB,/B) to sample values for the uncertain variable 7nit (ost, and
cell #<; contains a formula E3si'ean(#B) to obtain the mean value of 2et 3rofit
across all trials of the simulation.
& portion of an e*ample model in the (F programming language might look like this,
where the array \$arGH receives sample values for the two uncertain variables I and >,
and the uncertain function values are computed and assigned to the 3roblem.s
/cn7ncertain ob)ect \$alue property:
Model Sim'lification
Jike all models, a risk analysis model is a simplification and appro*imation of reality.
1he art of modeling involves choices of what essential factors must be included, and
what factors may be ignored or safely e*cluded from the model. &s &lbert 0instein
suggested, a model should be +as simple as possible, but no simpler.+
,e must also choose what sample values to test for the uncertain variables.
imulation software such as Risk olver lets us draw sample values from scores of
different probability distributions. ,hile we should do our best to choose the right
sample values, we derive a great benefit simply by moving from fi*ed values to
almost any reasonable sample of values for an uncertain "uantity.
5r. am avage likes to use the analogy of shaking a ladder before you use it to climb
up on a roof. ,hen you do this, you sub)ect the ladder to a random set of forces, to
see how it behaves. 0ven though the forces when you are shaking are not distributed
in the same way as the forces when you are climbing, shaking a ladder is still a good
Risk Analysis - Tools
Risk analysis tools are used to create a risk model, perform simulations using the
model, and analy4e the results. &n 0*cel spreadsheet can be a simple, yet powerful
tool for creating your model -- especially when paired with 'onte (arlo simulation
software such as Risk olver. -f your application calls for a programming language,
'onte (arlo simulation toolkits like the one in /rontline.s olver 3latform 5C
provide powerful aids.
& special-purpose simulation modeling language can be a productive tool, but we
must consider its non-simulation-related capabilities: /or e*ample, how easy is it to
access e*ternal databases in the simulation language, or embed a model in this
language in a larger application program6 uch a language is most useful if your
application calls for discrete event simulation, as opposed to 'onte (arlo simulation.
/or e*ample, a manufacturing process with many different +flows+ of materials, and
many steps taking place over time could be a candidate for a simulation modeling
language.
• Running a Risk &nalysis 'odel
• 1rials, ampling, and &ccuracy
• &naly4ing 'odel Results
Runnin+ a Risk Analysis Model
!nce we have a complete model in a form appropriate for our chosen risk analysis
tool, we can e*ecute or +run+ it, performing one or more simulations, to get results.
,e want the software to do the work, since it would take many hours to run the model
manually, thousands of times.
1he basic step in a simulation run, called a trial, is very simple:
<. (hoose sample values for the uncertain variables, and +plug them into+ the
model.
=. 0valuate the model: Run the program, or recalculate the spreadsheet.
@. !bserve and record the values of the uncertain functions.
/or models with few uncertain variables, where the possible values of these variables
cover a limited range, it may be possible to run a series of trials, where we
systematically +step through+ the range of each variable, in all combinations. /or
e*ample, if we had two variables, I ranging from < to <;; and > ranging from <; to
:; in steps of :, we.d perform a trial with I E < and > E <;, then I E < and > E <:,
and so on for a total of B;; trials. #ut for most models of any si4e, this approach is
impractical: ,e would need millions or even billions of trials, and running them all
might not actually tell us very much.
8ence, simulation normally relies on random sampling of values for the uncertain
variables: -n step < above, we draw one or more random numbers -- analogous to
flipping a coin or rolling dice on the computer -- and we use these numbers to
randomly select sample values from the range of possible values (the distribution) of
each uncertain variable. -f we do this effectively (using high-"uality random number
generation and sampling methods), we can obtain e*cellent +coverage+ of the possible
values and model outcomes -- even if the model has many uncertain variables.
Trials, Sam'lin+, and Accuracy
& simulation can be run for as many trials as you specify. 1o obtain more accurate
results, you must run more trials -- so there is a tradeoff between accuracy of the
results, and the time taken to run the simulation. #ut there are several ways you can
improve this tradeoff, and obtain good accuracy in a limited amount of time:
• 0nsure that each trial runs as fast as possible. -f you create your model in a
compiled programming language, it can e*ecute trials at the fastest possible
speed -- but this usually re"uires more development time. Running a model in
0*cel is slower, since your 0*cel formulas must be interpreted on each
simulation run. #ut you can take advantage of 3- 1echnology in /rontline.s
Risk olver software to run trials hundreds of times faster than using 0*cel
alone.
• 7se a sampling method that provides better coverage of the possible values of
variables, and lower variance (higher accuracy) for the outcomes, than
standard 'onte (arlo sampling for the same number of trials. 1wo advanced
methods are Jatin 8ypercube sampling and obol numbers, which are an
alternative to simple random numbers. /rontline.s Risk olver and olver
3latform 5C support both of these advanced sampling methods.
• /or demanding applications, such as those found in "uantitative finance, use
multiple streams of random numbers in combination with a high "uality, long
period random number generator to minimi4e any dependencies between
samples for your uncertain variables. &gain these capabilities are available in
/rontline.s Risk olver and olver 3latform 5C.
Analy*in+ Model Results
#ecause a simulation yields many possible values for the outcomes we care about --
from 2et 3rofit to environmental impact -- some work is needed to analy4e the
results. -t is very useful to create charts to help us visuali4e the results -- such as
fre"uency histogram charts and cumulative fre"uency charts. ,e can summari4e the
range of outcomes using various kinds of statistics, such as the mean or median, the
standard deviation and variance, or the :th and B:th percentile or \$alue at Risk.
&nother powerful tool for assessing model results is sensitivity analysis, which can
help us identify the uncertain inputs with the biggest impact on our key outcomes.
/or e*ample, a tornado chart can give us a "uick visual summary of the uncertainties
with the greatest positive and negative impact on 2et 3rofit. 7sing software, we can
also run multiple simulations, with an input we choose taking a different value on
each simulation, and assess the results. &naly4ing the model can give us more
information, but also insight about our real-world problem.
Risk Analysis - Software
Risk analysis software covers a wide spectrum of capabilities and price points, from
under-9<,;;; general-purpose packages to 9<;;,;;; and much higher priced packages
tailored for banks, insurance companies and enterprise risk managers in large
corporations. !ur focus here is on lower-cost general-purpose packages that offer
great fle*ibility, but re"uire that you +roll your own+ risk analysis model. 1he most
popular packages perform 'onte (arlo simulation of models created in 'icrosoft
0*cel, with a surprising range of technical capabilities.
ome capabilities to look for in a general-purpose package include:
• 8igh-"uality (long-period and well-e"uidistributed) random number
generation
• Jatin 8ypercube and/or %uasi 'onte (arlo based sampling for variance
reduction
• & wide range of analytic probability distributions -- leading packages have M;
or more
• /le*ible creation of custom distributions, both continuous and discrete
• &bility to correlate dissimilar distributions, typically via rank order correlation
• &bility to fit analytic distributions to user-supplied data or to simulation
results
• tatistics to measure central tendency and variation, "uantile measures, and
confidence intervals
• 0asily created but customi4able charts and graphs of 35/s, (5/s, fre"uencies
and cumulative fre"uencies
• ensitivity analysis of outputs against uncertain inputs
• &bility to run multiple simulations, varying parameters across the simulations
ome advanced capabilities available in the best packages include:
• hifting and truncation of analytic distributions
• -ndependent streams of random numbers for different distributions
• &bility to run +trace simulations+ using pre-generated simulation trials
• &bility to model conditional distributions in simulation results
• &bility to find optimal or near-optimal decisions using simulation
optimi4ation
• &bility to create (analytic or custom) distributions and share them among
modelers
• &bility to create custom risk analysis applications, and distribute them to end
users
• &nd of course, the fastest possible e*ecution of simulation trials
/inally, technical support and upgrades are a very important part of any software
product that will be used for high-stakes risk analysis pro)ects. 1he leading
companies in this area have been selling and supporting software for more than <:
years? all of them offer, and charge for, +annual support+ which includes software
-t should come as no surprise that /rontline ystems. new Risk olver product has
been engineered to include all of the standard and advanced capabilities mentioned
here. #ut there.s no need to +take our word for it+ -- you can download and install
Risk olver and use it, free of charge, for a <:-day evaluation period.
Monte Carlo Simulation Tutorial - &ntroduction
,elcome to our tutorial on 'onte (arlo simulation -- from /rontline ystems,
developers of the 0*cel olver and Risk olver software. -n the ne*t few pages, we.ll
show how you can convert a conventional spreadsheet model of a business plan sales
forecast -- one that yields a flawed +average+ 2et 3rofit forecast based on average
inputs -- into a far more realistic and useful simulation model that reveals the full
range of 2et 3rofit outcomes. &nd we.ll show the power of Risk olver software with
-nteractive imulation -- which 5r. am avage calls +a cure for the /law of
&verages.+
,aitN ,hat is 'onte (arlo simulation6 (onsult our 'onte (arlo imulation
• ,hat is 'onte (arlo imulation6
• ,hy hould - 7se 'onte (arlo imulation6
• ,hat Cnowledge 5o - 2eed to 7se -t6
• 8ow ,ill 1his 8elp 'e in 'y ,ork or (areer6
/or background on simulation analysis and simulation models, consult our imulation
-ntroduction. /or background on risk analysis, consult our Risk &nalysis !verview.
!ur Risk &nalysis 1utorial is designed to sharpen your thinking about uncertainty and
risk, and how to identify and "uantify the uncertainties you face.
A \$usiness %lannin+ ()am'le
-magine you are the marketing manager for a firm that is planning to introduce a new
product. >ou need to estimate the first year profit from this product, which will
depend on:
• ales in units
• 3rice per unit
• 7nit cost
• /i*ed costs
3rofit will be calculated as 3rofit E ales O (3rice - 7nit cost) - /i*ed costs. /i*ed
costs (for overhead, advertising, etc.) are known to be 9<=;,;;;. #ut the other factors
all involve some uncertainty. ales in units can cover "uite a range, and the selling
price per unit will depend on competitor actions. 7nit costs will also vary depending
on vendor prices and production e*perience.
ncertain -aria.les
1o build a risk analysis model, we must first identify the uncertain variables -- also
called random variables. ,hile there.s some uncertainty in almost all variables in a
business model, we want to focus on variables where the range of values is
significant.
Sales and %rice
#ased on your market research, you believe that there are e"ual chances that the
market will be low, !C, or 8ot.
• -n the +low market+ scenario, you e*pect to sell :;,;;; units at an average
selling price of 9<<.;; per unit.
• -n the +!C market+ scenario, you e*pect to sell P:,;;; units, but you.ll likely
reali4e a lower average selling price of 9<;.;; per unit.
• -n the +8ot market+ scenario, you e*pect to sell <;;,;;; units, but this will
bring in competitors who will drive down the average selling price to 9Q.;;
per unit.
nit Cost
&nother uncertain variable is 7nit (ost. >our firmRs production manager advises you
that unit costs may be anywhere from 9:.:; to 9P.:;, with a most likely cost of 9D.:;.
1he most likely cost is also the average cost.
ncertain /unctions
0et %rofit
!ur ne*t step is to identify uncertain functions -- also called functions of a random
variable. 2et 3rofit is calculated as 3rofit E ales O (3rice - 7nit cost) -/i*ed costs.
ales \$olume, elling 3rice and 7nit (ost are all uncertain variables, so 2et 3rofit is
an uncertain function.
The /lawed Avera+e Model
&t this point, we can summari4e the problem in the 0*cel model pictured below,
which calculates 2et 3rofit based on average sales, price, and unit cost.
1he 2et 3rofit figure of 9<<P,P:; calculated by this model, based on average values
for the uncertain factors, is "uite misleading, as weRll see in a moment. 1he true
average 2et 3rofit is closer to 9B@,;;;N &s 5r. am avage warns, +3lans based on
average assumptions will be wrong on average.+
Monte Carlo Simulation Tutorial - &ntroducin+ ncertainty
1o turn the spreadsheet model on the previous page into a risk analysis model, we
need to replace the fi*ed ales \$olume, elling 3rice, and 7nit (ost amounts with
variable amounts that reflect their uncertainty.
Sales and %rice
ince there are e"ual chances that the market will be will be low, !C, or 8ot, we
want to create an uncertain variable that selects among these three possibilities, by
drawing a random number -- say <, = or @ -- with e"ual probability. ,e can do this
easily in Risk olver using an integer uniform probability distribution. ,e.ll then
base on ales \$olume and elling 3rice on this uncertain variable.
,ith cell #B selected, we click the 5iscrete button on the Risk olver Ribbon. 1his
displays a dropdown gallery of discrete probability distributions. (& sample drawn
from a discrete distribution is always one of a set of discrete values, such as integer
numbers.) ,e click to choose +-nt7niform+ from the gallery.
Risk olver displays the 7ncertain \$ariable dialog with a chart of the integer uniform
distribution -- initially with parameters lower ; and upper <;. ,e edit these
parameters to read lower < and upper @. 1his means that on each trial, we.ll draw a
number <, = or @ from this distribution.
,hen we click the ave icon in the dialog toolbar, a formula E3si-nt7niform(<,@) is
written to #B. #B is now an uncertain variable. -f we now press /B to recalculate the
spreadsheet, a different value -- either <, = or @ -- appears each time in cell #B.
2ow, we need to select one of the three sales scenarios in formulas for ales \$olume
and elling 3rice. ,ith cell #M selected, we enter the formula:
E(8!!0(#B,0:,0D,0P) for ales \$olume
1his will cause #M to return <;;,;;;, P:,;;;, or :;,;;;, depending on the value in
#B. 2e*t, with cell #: selected, we enter the formula:
E(8!!0(#B,/:,/D,/P) for elling 3rice
1his will cause #: to return 9Q, 9<; or 9<<, depending on the value in #B.
2otice that the values returned by #M and #: are related, or correlated: 8igher sales
volume is accompanied by lower selling prices, and vice versa. -f we allowed
scenarios with <;;,;;; units sold at 9<< each, our model would be unrealistic. Risk
olver supports more versatile ways to specify correlation between uncertain
variables, but this approach is easy to understand in this e*ample.
Monte Carlo Simulation Tutorial - &ntroducin+ ncertainty Continued
o far, we.ve modified our spreadsheet model to introduce uncertainty for ales
\$olume at cell #M and elling 3rice at #:. 2ow we.ll deal with 7nit (ost. ,e have
not )ust three, but many possible values for this variable: -t can be anywhere from
9:.:; to 9P.:;, with a most likely cost of 9D.:;. & crude but effective way to model
this is to use a triangular distribution. Risk olver provides a function called
3si1riangular() for this distribution.
,ith cell #D selected, from the Risk olver Ribbon we click the (ontinuous button to
display a dropdown gallery of continuous probability distributions. (7nlike a discrete
distribution, a sample drawn from a continuous distribution can be any numeric value,
such as :.Q or D.;<, in a range.) ,e choose +1riangular+ from the gallery.
Risk olver displays the 7ncertain \$ariable dialog with a chart of the triangular
distribution -- initially with parameters min ;, likely < and ma* @. ,e want to edit
these parameters -- but instead of entering fi*ed numbers, we.ll use the range selector
icon at the right of each field to select cells containing the parameters: min 0<<
(9:.:;), likely 0<= (9D.:;) and ma* 0<@ (9P.:;).
1his means that on each trial, we.ll draw a number between 9:.:; and 9P.:;, where
9D.:; is the most likely value to be drawn -- as shown in the chart of the triangular
distribution below. 8ence 9D.M: and 9D.:: are more likely than 9:.:: or 9P.M: -- but
any of these and other numbers has a chance of being drawn on each trial. ,hen we
click the ave icon in the dialog toolbar, a formula E3si1riangular(0<<,0<=,0<@) is
written to #D. ,e now have a second uncertain variable in our model.
2e*t, we.ll move on to define an 7ncertain /unction. #ut we can do much more than
shown here with the 7ncertain \$ariable dialog: 1he view above shows all of its panes
open (click the image to see it full si4e). >ou can browse different distributions, shift
and truncate a distribution, see each distribution.s 3robability 5ensity /unction
(35/), (umulative 5ensity /unction ((5/) or Reverse (5/, see statistics and
percentiles for the distribution, automatically fit a distribution to user-supplied data,
and customi4e the chart.
Monte Carlo Simulation Tutorial - ncertain /unctions and Statistics

,eRve now defined the uncertain variables in our risk analysis model. &nything
calculated from these uncertain variables is an uncertain function, but usually weRre
interested only in specific results such as 2et 3rofit at cell #<<. ,hen we Kturn onL
-nteractive imulation, #<< will effectively hold an array of values, each one
calculated from different values sampled for #M, #:, #D and #P.
,hat would we like to know about the array of values for 2et 3rofit at cell #<<6 1he
simplest summary result is the average (or mean) 2et 3rofit. 2ote that this will be the
true average of 2et 3rofit across <,;;; or more scenarios or trials -- not a single
calculation from average values of the inputs. ,ith cell #<< highlighted, we click the
tatistics button on the Risk olver Ribbon. & dropdown gallery shows us the
available statistics functions, which we can +drag and drop+ into a worksheet cell.
,hen we click the 'ean button, a small KballoonL like the one below appears and
follows the mouse pointer as we move to a worksheet cell, in this case #<=. ,hen we
click to select the cell, the formula E3si'ean(#<<) appears in the cell.
,hen we define a summary statistic, such as 3si'ean(#<<), weRve implicitly
designated cell #<< as an uncertain function. Risk olver will keep track of the full
range of trial values for #<< during a simulation, and will display fre"uency and
sensitivity charts, statistics and percentiles for it on demand. &s noted above, in
principle anything calculated from the uncertain variables is an Kuncertain functionL --
but to save time and memory, Risk olver keeps track of trial values only for the
formula cells that we designate. 1here are several ways (besides using a statistic such
as 3si'ean) to designate a cell as an uncertain function.
Monte Carlo Simulation Tutorial - sin+ &nteractive Simulation

o far, we.ve modified an ordinary spreadsheet model by defining selected cells as
uncertain variables, and one cell (2et 3rofit) as an uncertain function. 1hat.s itN -- we
have a risk analysis model in the form re"uired by Risk olver software. ,e.re now
ready to run a 'onte (arlo simulation, and see how uncertainty affects our
,ith an old-fashioned simulation software package, you.d press a button to start a
simulation, then perhaps get a cup of coffee. #ecause simulations ran slowly,
software packages were designed for +batch+ operation: >ou.d spend time getting
everything set up )ust right, run a simulation and wait (sometimes "uite a while), then
spend time analy4ing the results. #ut with Risk olver, simulations run so fast that
fully -nteractive imulation is practical.
1o turn on -nteractive imulation, we simply click the light bulb on the Ribbon. -t will
Klight up,L as shown below. -n the blink of an eye, your first 'onte (arlo simulation
is completeN
/rom now on (until we click the light bulb again to turn it off), <,;;; 'onte (arlo
simulation trials (the default number) will be run each time you change the
spreadsheet, and cell #<= will display the true average for 2et 3rofit across these
<,;;; trials:
1he result of Kshaking the ladderL is striking: !ur true average 2et 3rofit for these
<,;;; trials is only 9B@,MB@ S "uite a bit less than the /lawed &verage 'odel figure of
9<M=,;;;N &nd we also see that we can lose money -- the last of the <,;;; trials,
which appears on the worksheet, shows a loss of 9=<,<:@.
1ry pressing /B (the 0*cel recalculate key) on this model: 0ach time you do, another
<,;;; 'onte (arlo trials are run, and a slightly different true average 2et 3rofit figure
will be displayed -- but nearly always much less than 9<M=,;;;.
Monte Carlo Simulation Tutorial - -iewin+ the /ull Ran+e of %rofit Outcomes
,e.ve turned our spreadsheet model into a risk analysis model, and we.ve turned on
-nteractive imulation. !ne immediate insight is that the mean or true average 2et
3rofit, over <,;;; different simulated outcomes, is much less than we e*pected from
our naTve K/lawed &verageL model. ,eRve also seen that in some outcomes, our 2et
3rofit is actually a loss.
& "uick look at the dropdown galleries for tatistic, Risk 'easure and Range on the
Risk olver Ribbon suggests that we can easily compute and view many other
statistics about 2et 3rofit. #ut weRd really like to see the full range of outcomes in
this model. 1his is very easy to do in Risk olver.
,ith -nteractive imulation turned on, simply move the mouse pointer to #<< and
wait about < second. & miniature, live fre"uency distribution chart of the simulation
trial values for cell #<< appears automatically:
1o see and do more, )ust double-click on #<<, the cell calculating 2et 3rofit, to
display Risk olver.s 7ncertain /unction dialog, with a customi4able fre"uency chart
of these outcomes, as shown below:
,e see immediately that in some outcomes, we can lose of lot of money -- more than
9:;,;;;N ,e also see that we make a profit in most outcomes -- but how many
e*actly6 ,ith Risk olver, we can point and click on the chart to find out, as shown
on the ne*t page.
Monte Carlo Simulation Tutorial - /ocusin+ on %rofita.le Outcomes

!ur risk analysis model is now showing us the full range of outcomes for 2et 3rofit.
,e see that in some outcomes, we can lose of lot of money -- more than 9:;,;;;N ,e
also see that we make a profit in most outcomes -- but how many e*actly6 -n Risk
olver, by )ust right-clicking over the chart and selecting &dd Jower, we can "uickly
put a vertical bar at ; on the hori4ontal a*is:
,hen we do this, the (ertainty bo* at the bottom is updated to reflect the percentage
of outcomes still in the blue region. (>ou can also place a vertical bar on the upper
part of the hori4ontal a*is, if you wish.) ,e see that we make a profit in about B=U of
the outcomes.
&nother view of the full range of outcomes is shown on the (umulative /re"uency
tab. 0ach bar on this tab shows the fre"uency with which 2et 3rofit was less than or
e"ual to the value on the hori4ontal a*is. ,e can also look at this information
numerically with percentiles, as shown on the ne*t page.
Monte Carlo Simulation Tutorial - Statistics and %ercentiles
o far in our business forecast risk model, we.ve looked at charts of the full range of
2et 3rofit outcomes, in the form of fre"uency and cumulative fre"uency charts. 1he
3ercentiles tab in the Risk olver 7ncertain /unction dialog shows the same
information as the (umulative /re"uency tab, but in numeric form. -n the chart below,
weRve scrolled down to show the :;th through DMth percentile values:
,hile we.re looking at numbers, let.s click on the tatistics tab, which displays
summary statistics for the full range of 2et 3rofit outcomes. ,e can see that the
worst case outcome of this simulation was -9D=,MMD, and the best case outcome was V
9=<;,;<=. \$alue at Risk B:U shows that we have a :U chance of losing 9<<,@MQ or
more, and (onditional \$alue at Risk B:U shows that the average of all the possible
losses we might reali4e beyond the \$aR B:U level is 9@@,=BQ.
2ow we have a pretty good idea of the full range of outcomes for 2et 3rofit. -n a
conventional what-if spreadsheet model, we.d now be asking +8ow can we increase
2et 3rofit6+ #ut with a risk analysis model, we can also ask and answer "uestions
like +8ow can we reduce the chance of a loss6+ and +8ow can we reduce the
variability of 2et 3rofit6+ ensitivity analysis can help us answer all these "uestions,
as discussed on the ne*t page.
Monte Carlo Simulation Tutorial - Sensitivity Analysis

,e.ve converted our spreadsheet model to a risk analysis model, run a 'onte (arlo
simulation with Risk olver, and e*amined the full range of outcomes for 2et 3rofit
through statistics and percentiles, charts and graphs. 2ow we can begin to take steps
towards risk management: 7sing the model to determine how we can reduce the
chance of a loss -- and increase the chance of a (larger) profit.
1he ensitivity tab in the 7ncertain /unction displays a 1ornado chart that shows you
how much 2et 3rofit changes with a change in the uncertain variables -- our integer
uniform distribution at cell #B, and the triangular distribution for 7nit (ost at cell #D.
-n this model there are only two uncertain variables, but in a large model with many
such variables, itRs usually not obvious which ones have the greatest impact on
outcomes such as 2et 3rofit. & 1ornado chart highlights the key variables, as shown
below:
!ur 7nit (ost at cell #D is negatively correlated with 2et 3rofit, as e*pected: 8igher
7nit (osts leads to lower 2et 3rofits. 2otice that our integer uniform distribution at
cell #B is positively correlated with 2et 3rofit: ,hat does this mean6
ince we used E(8!!0(#B,0:,0D,0P) for ales \$olume, on each trial where #B is
< we use <;;,;;; units sold? when #B is = we use P:,;;; units sold? and when #B is @
we use :;,;;; units sold. 1he fact the #B is positively correlated with 2et 3rofit is
telling us that we make higher profits when the market is slow, not when it.s hot. !ur
typical elling 3rice is lower when the market is hot, and the increased ales \$olume
doesn.t make up for this.
1he state of the market is outside of our company and our direct control. #ut our
production costs, while variable and uncertain, are more sub)ect to our control.
8aving seen that our 2et 3rofit suffers in a hot market because of the narrow margin
we have between our typical elling 3rice and our 7nit (ost, we.re motivated to try to
improve this situation.
,e want to ask +what if our (uncertain) 7nit (osts could be reduced6+ -- in the
presence of our uncertain ales \$olume and elling 3rice. Risk olver empowers us
to ask and answer e*actly this "uestion, as shown on the ne*t page.
Monte Carlo Simulation Tutorial - &nteractive Simulation with Charts and
1ra'hs

-nteractive imulation makes Risk olver fundamentally different from other 'onte
(arlo simulation tools for 0*cel. 1he kinds of charts weRve )ust seen can be produced
by other tools, but only at the end of a Ksimulation run.L -n contrast, Risk olver
makes these charts live as you play what-if with your model.
&fter seeing this model, your production manager might think of a way to reduce the
ma*imum 7nit (ost to 9P.;; instead of 9P.:;. ,hat would be the impact of this
change on 2et 3rofit, over the full range outcomes6 ,ith Risk olver, this is as easy
as any other Wwhat-ifR "uestion in 0*cel.
,e click the /re"uency tab in the 7ncertain /unction to re-display the fre"uency
chart of outcomes for cell #B. 1hen simply change the number in cell 0<@ -- the high
end of the 7nit (ost distribution -- from P.:; to P.;;. (1he other parameters of our
triangular distribution -- low 9:.:;, most likely 9D.:; -- haven.t changed.)
-mmediately, a thousand 'onte (arlo trials are performed, and the chart is updated.
1he effect is striking: ,e have better than a BQU chance of making a profit, and --
checking the tatistics tab -- we see that instead of a worst-case loss of -9D=,MMD, we
have a worst-case loss of only -9<M,M=<N
picture of this business situation. -n contrast, the Risk olver model has illuminated
the situation considerably. ,e can see what can go right, and what can go wrong. ,e
can make an informed decision about whether the reward is worth the risk. &nd --
most important -- we can interactively e*plore ways to improve the reward and reduce
the risk. 1his is risk analysis and risk management at work.
,e.ve now progressed all the way through the process of building a simulation model
and using 'onte (arlo simulation for risk analysis and decision-making. #ut most
often, completing the analysis doesn.t mean we are finished -- we must present our
results to others. &nd this e*ample model was very small -- most realistic models will
contain many more uncertain variables and functions, statistics, correlations and other
features. ,e.ll e*plore how Risk olver can help us with these issues in two
concluding pages.
Monte Carlo Simulation Tutorial - Charts and 1ra'hs for %resentations
!ften, you may be called up to present your results to others. ,ith Risk olver, one
great way to do this is in 0*cel itself, liveN #ut you can "uickly create high-"uality
charts and graphs of your results, print them, or copy and paste them into 3ower3oint
or any ,indows application. >ou can control chart color, dimensionality and
transparency, bin density, titles and legends, a*is labels and number formats,
hori4ontal a*is scaling, and more.
Xust as Risk olver charts update instantly when you change numbers on the
spreadsheet, they also update instantly when you change colors, titles, gridlines,
legends and other options. !nce you have the chart formatted )ust the way you want,
you can use the toolbar buttons in the title bar of the dialog to +e*port+ the chart.
(lick the (lipboard icon to copy the currently displayed chart to the ,indows
(lipboard. >ou can then choose 0dit 3aste in ,ord, 0*cel, 3ower3oint and many
other applications to paste the chart image into your document. (lick the 3rint icon to
immediately print the currently displayed chart on your default printer, or click the
down arrow ne*t to this icon to display the menu choices shown above. >ou can
choose a printer and set printer options, set page margins, and preview your output
Monte Carlo Simulation Tutorial - -iewin+ a Summary of the Model

-n this tutorial, weRve used Risk olver to define two uncertain variables (our integer
uniform distribution and our 7nit (ost), one uncertain function (2et 3rofit), and one
summary statistic (the 'ean or 1rue &verage). -n a larger model, we might define a
great many uncertain variables and functions, statistics, and correlation matrices on a
worksheet. 1hey might even be spread across multiple worksheets in a workbook.
8ow do we find them6 ince all of Risk olverRs function start with W3siR, we could
use the 0*cel /ind function to search for formulas containing this string. #ut Risk
olver provides an easier way.
(lick the 'odel button on the Risk olver Ribbon to display a summary of your
entire risk analysis model in outline form, as shown below. >ou can e*pand and
collapse outline groups by clicking the V or - icons that appear in this display. >ou
can "uickly locate cells containing uncertain variables, uncertain functions, statistics,
or correlation matrices. >ou can even step through trials of the most recent
simulation, displaying them on the spreadsheet.
,hen -nteractive imulation is on, moving the mouse pointer over one of the
uncertain variable or uncertain function cell addresses will display a miniature 35/ or
fre"uency chart for that variable or function -- giving you an instant summary of the
behavior of your model. & single-click on any of the cells displayed here will move
the 0*cel selection to that cell. & double-click will open the Risk olver dialog --
7ncertain \$ariable, 7ncertain /unction, or (orrelation -- that you use to work with
that cell.
1his concludes our 'onte (arlo imulation 1utorial -- we hope you.ve en)oyed itN -f
you haven.t done so already, consult our Risk &nalysis 1utorial -- it.s designed to
sharpen your thinking about uncertainty and risk, and how to identify and "uantify the
uncertainties you face. /or background on simulation analysis and simulation
models, consult our imulation -ntroduction.
Simulation - &ntroduction

imulation is a fle*ible methodology we can use to analy4e the behavior of a present
or proposed business activity, new product, manufacturing line or plant e*pansion,
and so on (analysts call this the .system. under study). #y performing simulations and
analy4ing the results, we can gain an understanding of how a present system operates,
and what would happen if we changed it -- or we can estimate how a proposed new
system would behave. !ften -- but not always -- a simulation deals with uncertainty,
in the system itself, or in the world around it.
• imulation &pplications
• imulation 'odels
• imulation 'ethods
• 'onte (arlo imulation
Simulation A''lications
imulation is one of the most widely used "uantitative methods -- because it is so
fle*ible and can yield so many useful results. 8ere.s )ust a sample of the applications
where simulation is used:
• (hoosing drilling pro)ects for oil and natural gas
• 0valuating environmental impacts of a new highway or industrial plant
• etting stock levels to meet fluctuating demand at retail stores
• /orecasting sales and production re"uirements for a new drug
• 3lanning aircraft sorties and ship movements in the military
• 3lanning for retirement, given e*penses and investment performance
• 5eciding on reservations and overbooking policies for an airline
• electing pro)ects with uncertain payoffs in capital budgeting
Simulation Models
-n a simulation, we perform e*periments on a model of the real system, rather than the
real system itself. ,e do this because it is faster, cheaper, or safer to perform
e*periments on the model. ,hile simulations can be performed using physical
models -- such as a scale model of an airplane -- our focus here is on simulations
carried out on a computer. uch simulations use a mathematical model of the real
system. -n such a model we use variables to represent key numerical measures of the
inputs and outputs of the system, and we use formulas, programming statements, or
other means to e*press mathematical relationships between the inputs and outputs.
0ach e*periment is called a trial, and a simulation run includes many -- often
thousands of -- such trials.
,hen the simulation deals with uncertainty, the model will include uncertain
variables -- whose values are not under our control -- as well as decision variables or
parameters that we can control. !ur simulation model -- often called a risk model --
will calculate the impact of the uncertain variables and the decisions we make on
outcomes that we care about, such as profit and loss, investment returns,
environmental conse"uences, and the like. &s part of our model design, we must
choose how numerical values for the uncertain variables will be sampled on each trial.
Simulation Methods
(omple* manufacturing and logistics systems often call for discrete event simulation,
where there are +flows+ of materials or parts, people, etc. through the system, and
many steps or stages with comple* interrelationships. pecial simulation modeling
languages are often used for these applications.
#ut a great many situations -- including almost all of the e*amples above -- have been
successfully handled with simulation models created in a spreadsheet using 'icrosoft
0*cel. 1his minimi4es the learning curve, since you can apply your spreadsheet skills
to create the model. imple steps or stages, such as inventory levels in different
periods, are easy to represent in columns of a spreadsheet model. >ou can solve a
wide range of problems with 'onte (arlo simulation of models created in 0*cel, or in
a programming language such as \$isual #asic, (VV or (F.
Running a simulation generates a great deal of statistical data, that must be analy4ed
with appropriate tools. 3rofessional simulation software, such as /rontline ystems.
Risk olver, allows you to easily create charts and graphs, a wide range of statistics
and risk measures, perform sensitivity analysis and parameteri4ed simulations, and
&nalysis.
Monte Carlo Simulation
'onte (arlo simulation -- named after the city in 'onaco famed for its casinos and
games of chance -- is a powerful method for studying the behavior of a system, as
e*pressed in a mathematical model on a computer. &s the name implies, 'onte (arlo
methods rely on random sampling of values for uncertain variables, that are +plugged
into+ the simulation model and used to calculate outcomes of interest. ,ith the aid of
software, we can obtain statistics and view charts and graphs of the results. 1o learn
more, consult our 'onte (arlo simulation tutorial.
'onte (arlo simulation is especially helpful when there are several different sources
of uncertainty that interact to produce an outcome. /or e*ample, if we.re dealing with
uncertain market demand, competitors. pricing, and variable production and raw
materials costs at the same time, it can be very difficult to estimate the impacts of
these factors -- in combination -- on 2et 3rofit. 'onte (arlo simulation can "uickly
analy4e thousands of .what-if. scenarios, often yielding surprising insights into what
can go right, what can go wrong, and what we can do about it.
Simulation Model - &ntroduction
& simulation model is a mathematical model that calculates the impact of uncertain
inputs and decisions we make on outcomes that we care about, such as profit and loss,
investment returns, environmental conse"uences, and the like. uch a model can be
created by writing code in a programming language, statements in a simulation
modeling language, or formulas in a 'icrosoft 0*cel spreadsheet. Regardless of how
it is e*pressed, a simulation model will include:
• 'odel inputs that are uncertain numbers -- we.ll call these uncertain variables
• -ntermediate calculations as re"uired
• 'odel outputs that depend on the inputs -- we.ll call these uncertain functions
-t.s essential to reali4e that model outputs that depend on uncertain inputs are
uncertain themselves -- hence we talk about uncertain variables and uncertain
functions. ,hen we perform a simulation with this model, we will test many
different numeric values for the uncertain variables, and we.ll obtain many different
numeric values for the uncertain functions. ,e.ll use statistics to analy4e and
summari4e all the values for the uncertain functions (and, if we wish, the uncertain
variables).
• (reating 'odels in 0*cel or (ustom 3rograms
• (hoosing amples for 7ncertain \$ariables
Creatin+ Models in ()cel or Custom %ro+rams
&n 0*cel spreadsheet can be a simple, yet powerful tool for creating your model --
especially when paired with 'onte (arlo simulation software such as Risk olver. -f
your model is written in a programming language, 'onte (arlo simulation toolkits
like the one in /rontline.s olver 3latform 5C provide powerful aids.
&n e*ample model in 0*cel might look like this, where cell #D contains a formula
E3si1riangular(0B,AB,/B) to sample values for the uncertain variable 7nit (ost, and
cell #<; contains a formula E3si'ean(#B) to obtain the mean value of 2et 3rofit
across all trials of the simulation.
& portion of an e*ample model in the (F programming language might look like this,
where the array \$arGH receives sample values for the two uncertain variables I and >,
and the uncertain function values are computed and assigned to the 3roblem.s
/cn7ncertain ob)ect \$alue property:
Choosin+ Sam'les for ncertain -aria.les
,e must also choose what random sample values to use for the uncertain variables.
5uring a simulation, a new sample value will be drawn on each trial. -n the simplest
case, we might generate random numbers between ; and <, and use these as sample
values. #ut in most cases, the range of values, and chance that different values in the
range will be drawn on each trial, must be tailored to the uncertain variable. 1o do
this, we normally choose a probability distribution and appropriate parameters for the
uncertain variable.
3robability 5istributions for imulation. ,e can choose:
• &n analytic distribution, such as a 7niform or 2ormal distribution
• & custom distribution, where we specify its form in detail
• & distribution fitted to past data on the behavior of the variable
• & smaller data set that is resampled for values on each simulation trial
• & larger data set, called a tochastic Jibrary, that supplies all of the samples
• & (ertified 5istribution that has been prepared and +vetted+ by an e*pert
/rontline.s Risk olver supports all of these options for obtaining sample values for
the uncertain variables in a simulation model.
%ro.a.ility #istri.utions for Simulation
/or e*perienced modelers, the most challenging task in creating a simulation model is
usually not identifying the key inputs and outputs, but selecting an appropriate
probability distribution and parameters to model the uncertainty of each input
variable. /or e*ample, Risk olver software provides over M; analytic probability
distributions -- which one should you use6 1he answer depends on your application,
but some general guidelines can be given.
• 5iscrete \$s. (ontinuous 5istributions
• #ounded \$s. 7nbounded 5istributions
• &nalytic \$s. (ustom 5istributions
• 'ore 8ints and ,arnings
• (hoosing a 5istribution
#iscrete -s2 Continuous #istri.utions
-f you must choose or create your own distribution, the first step is to determine
whether to use a discrete or continuous form.
-f there are a small number of possible values for the uncertain variable, you may be
able to use a discrete analytic distribution, or construct a discrete custom distribution.
-f the underlying physical process involves discrete, countable entities -- such as the
number of customers arriving at a service window -- you can use a discrete
distribution.
-f the possible values are highly divisible -- such as most prices, volumes, interest
rates, e*change rates, weights, distances, etc. -- you will likely use a continuous
distribution. -n some cases, you may use a continuous distribution to appro*imate a
discrete distribution.
\$ounded -s2 n.ounded #istri.utions
&nother characteristic that distinguishes probability distributions is the range of
sample values they can generate.
ome distributions are intrinsically bounded -- samples are guaranteed to lie between
a known minimum and ma*imum value. 0*amples are the 7niform, 1riangular, #eta,
and #inomial distributions.
!ther analytic distributions are unbounded -- sample values may cluster around the
distributionRs mean, but may sometimes have e*treme negative or positive values.
0*amples are the 2ormal, Jogistic, and 0*treme \$alue distributions.
till other distributions are partially bounded, with a known minimum such as 4ero,
but no ma*imum value. 0*amples are the 0*ponential, 3oisson, and ,eibull
distributions.
&t times, you may find that the most appropriate distribution (say the 2ormal) is
unbounded, but you know that the realistic values of the physical process are
bounded, or your model is designed to handle values only up to some realistic limit.
>our software may allow you to truncate an unbounded distribution. /or e*ample, in
Risk olver you can impose bounds on any distribution by passing the 3si1runcate
property function as an argument to the distribution function.
Analytic -s2 Custom #istri.utions
& third characteristic of probability distributions is whether they are analytic (also
called parametric) or custom (sometimes called non-parametric) distributions.

&n analytic distribution has a form derived from certain theoretical assumptions about
the problem. /or e*ample, a 3oisson distribution is derived from an assumption that
events are independent and occur at a known average rate, and an 0*ponential
distribution is derived from an assumption of a constant rate of decay in some
process.
& custom distribution has a form dictated by either past data or e*pert opinion about
the range and fre"uency of sample values. Risk olver software provides five
general-purpose functions -- 3si(umul, 3si5iscrete, 3si5is7niform, 3siAeneral and
Aenerally speaking, you should choose an analytic distribution if -- and only if -- the
theoretical assumptions truly apply in your situation.
More "ints and Warnin+s
sin+ a Trian+ular #istri.ution. -f you have only estimates of the minimum,
ma*imum, and most likely values of an uncertain variable -- and no other past data or
literature references -- a popular approach is to create a 1riangular distribution from
these three numbers. 1his is unlikely to be a highly accurate representation of the
uncertainty, but it will allow you to get started, and it is far better than a single
average that is sub)ect to the /law of &verages. -f your WminimumR and Wma*imumR
values are really low- and high-percentile estimates rather than the absolute lowest
and highest values that can occur, consider using a .generali4ed 1riangular.
distribution (3si1riangAen in Risk olver) instead.
#efine (ach ncertain -aria.le Only Once. !ften, youRll need to use the same
uncertain variable in several different formulas in your model. & very common error
is to enter the same distribution function, with the same parameters (say
3si2ormal(<;;, <;) in Risk olver), several times in a model -- in a belief that these
instances will yield the same results on each trial. 1his is incorrect -- by doing this,
youRve actually defined several independent uncertain variables that may well sample
different values on each trial. >ou should instead define E3si2ormal(<;;, <;) only
once (for e*ample in a cell such as &<), and use &< in every formula where the
uncertain variable is needed.
Choosin+ a %ro.a.ility #istri.ution
/or e*perienced modelers, the most challenging task in creating a simulation model is
usually not identifying the key inputs and outputs, but selecting an appropriate
probability distribution and parameters to model the uncertainty of each input
variable. /or e*ample, Risk olver software provides over M; analytic probability
distributions -- which one should you use6
• ,hen 3ast 5ata is &vailable
• ,hen 3ast 5ata is 2ot &vailable
When %ast #ata is Availa.le
-f you have, or you can collect data on the past performance of the uncertain variable
-- and if you believe that Wpast performanceR is likely to be representative of future
performance -- you have three options:
• -f you have a reasonably large number of observations of past performance of
the variable, compared to the number of simulation trials you want to run, you
can use the past data itself for simulation trials. 1his is sometimes called a
Ktrace-driven simulation.L -n Risk olver, you can use past data in the form of
a -3 (tochastic -nformation 3acket), and use the 3siip() or 3silurp()
distribution function for the uncertain variable.
• -f -- as is often the case -- you have a relatively small number of observations
of past performance compared to the number of trials you want to run, you
may be better off resampling the past performance data. -nstead of using all of
the past observations (one per simulation trial), you randomly sample the past
observations on each trial. -n Risk olver, you can place past data in a cell
range or -3, and use the 3si5is7niform() function (single values) or the
3siResample() function (multiple values) for the uncertain variable.
• -f you can fit the data (past observations) to a specific type of analytic
distribution and its parameters, and if there is reason to believe that the
underlying process that the uncertain variable is measuring is consistent with
the assumptions from which the analytic distribution is derived, you can use
this distribution (for e*ample 3si2ormal, 3si,eibull, etc.) for the variable.
>ou can use Risk olver to automatically find the best-fitting analytic
distribution.
When %ast #ata is 0ot Availa.le
-f you donRt have, and you cannot easily collect data on the past performance of the
uncertain variable -- or if past performance is not likely to be representative of future
performance -- you must tackle the problem in a different way:
• (onsult the literature for your industry, if available, to find e*amples of
applications like yours where simulation models were built. /ind out -- by
contacting the authors if necessary -- what kinds of distributions were used for
the uncertain variables, and the rationale for choosing them.
• -f you cannot find reports on industry-specific applications like yours, consult
the publications of professional societies like -2/!R', where simulation
applications are reported. !ne rich source is the past proceedings of the
,inter imulation (onference (www.wintersim.org).
• 1he Risk olver 7ser Auide has a chapter 3- /unction Reference, with
descriptions of M; different analytic and custom distribution functions,
including brief comments on the types of applications where each distribution
has been used in the past.
imulation 'odeling and &nalysis, Mth 0d. by &verill Jaw, tatistical
5istributions, @rd 0d. by 0vans, 8astings and 3eacock, 7nivariate 5iscrete
5istributions, @rd 0d. by Xohnson, Cemp and Cot4, or (ontinuous 7nivariate
5istributions, \$ol. < Y =, =nd 0d. by Xohnson, Cot4 and #alakrishnan.
>ou are well-advised to keep it simpleN 'any physical, social and biological
phenomena are well described by the 2ormal distribution, or -- if the possible values
are e"ually likely to occur, as in a coin flip or single die -- the 7niform distribution.
#ear in mind that when any set of distributions are summed, the result ("uickly) tends
towards the 2ormal distribution.
&pplications that involve "ueuing -- customers arriving or departing, parts awaiting
assembly, etc. -- have been well studied, so you can often find appropriate
distributions in the literature. &pplications that use the 3ro)ect 0valuation and
Review 1echni"ue (30R1) can often use the 3si3ert() function is Risk olver to
model uncertainty.
Simulation Analysis
-n simulation analysis, we create a mathematical model or a system or process,
usually on a computer, and we e*plore the behavior of the model by running a
simulation. & simulation consists of many -- often thousands of -- trials. 0ach trial is
an e*periment where we supply numerical values for input variables, evaluate the
model to compute numerical values for outcomes of interest, and collect these values
for later analysis.
• (harts and Araphs
• tatistical 'easures
• ensitivity &nalysis
• 3arameteri4ed imulation
• 2e*t: imulation !ptimi4ation
Charts and 1ra'hs
& simulation yields many possible values for the outcomes we care about -- from 2et
3rofit to environmental impact. 1he role of simulation analysis is to summari4e and
analy4e the results, in a way that will yield ma*imum insight and help with decision-
making. -t is very useful to create charts to help us visuali4e the results -- such as
fre"uency histogram charts and cumulative fre"uency charts.
tatistical 'easures
tatistics often play a key role in summari4ing the range of values for each outcome
of interest in a simulation analysis. ,hen the outcome is important to us, statistics
come to lifeN & good simulation software package, such as /rontline.s Risk olver,
provides a variety of statistics:
• 'easures of central tendency such as the mean, median and mode
• 'easures of variation such as the variance or standard deviation, skewness,
and kurtosis
• Risk measures such as mean absolute deviation, semivariance or lower partial
moment, and semideviation
• %uantile measures such as percentiles, cumulative targets, \$alue at Risk, and
(onditional \$alue at Risk
• (onfidence intervals that tell us how close our computed sample mean or
standard deviation is to the true value
-t.s important to look at "uantile measures, such as percentiles and \$alue at Risk, in
answer "uestions such as +8ow much money might we lose, with :U or <;U
probability6L or K,hat are the chances that weRll make at least 9<;;,;;;6L based on
& simulation uses a sample of the possible values of your uncertain variables? hence
any statistic resulting from the simulation involves some degree of sampling error.
(onfidence intervals help you assess this error, and estimate the range or interval in
which you can be confident that the true statistic lies, at a confidence level that you
specify.
Sensitivity Analysis
& powerful tool for assessing model results is sensitivity analysis, which can help us
identify the uncertain inputs with the biggest impact on our key outcomes. /or
e*ample, a tornado chart can give us a "uick visual summary of the uncertainties with
the greatest positive and negative impact on 2et 3rofit. 7sing software, we can also
run multiple simulations, with an input we choose taking a different value on each
simulation, and assess the results. &naly4ing the model can give us more information,
but also insight about our real-world problem.
%arameteri*ed Simulation
&nother powerful method for simulation analysis is running a parameteri4ed
simulation. -n this method, we run a series of simulations, where we vary the value of
one or more variable(s) that we can control -- such as our offering price, our inventory
restocking level, or our allocation of investment funds to different asset classes. 0ach
simulation run tests a wide range of values for the uncertain variables in our model,
collects results for our outcomes of interest, and produces summary statistics, charts
and graphs. ,e can then compare the different simulations to each other, to better
understand how varying the decision variable(s) affects our outcomes, in the presence
of uncertainty.
Simulation O'timi*ation
&n even more powerful method for simulation analysis, beyond parameteri4ed
simulation, is to use simulation optimi4ation to automatically find the best value of
one or more variables that we can control. ,e can put the computer to work, in effect
performing parameteri4ed simulations for many different combinations of values for
our decision variables, and seeking the best combination of values for criteria that we
specify.
/rontline.s 3remium olver or 3remium olver 3latform -- the leading optimi4ation
software for 'icrosoft 0*cel models -- works closely in concert with Risk olver to
find solutions to simulation optimi4ation problems -- at speeds up to <;; times faster
than other softwareN
• 8ow imulation !ptimi4ation ,orks
• 5efining a imulation !ptimi4ation 'odel
• olving a imulation !ptimi4ation 'odel
"ow Simulation O'timi*ation Works
1he overall process works like this: >our simulation model includes uncertain
variables whose values are defined by probability distributions. >ou can use the cells
containing these uncertain variables in any formula in your model. Risk olver
performs a simulation with thousands of trials, where a different value is sampled for
each uncertain variable on each trial, and your model is recalculated with these
values.
tatistics across all the trials are accumulated for any formula cell you designate. >ou
can access these statistics in regular 0*cel formulas. &nd with 3remium olver or
3remium olver 3latform, you can use these formulas in the ob)ective and constraints
of your optimi4ation model. /or e*ample, you could make average delivery time
(computed by your model, based on decisions and uncertainties) an ob)ective to be
minimi4ed, sub)ect to a constraint that the cost of inventory should, with B:U
probability, be less than a dollar threshold you specify.
#efinin+ a Simulation O'timi*ation Model
(reating a simulation optimi4ation model using 3remium olver and Risk olver is
<. 5efine decision variable cells (such as &<), using either the olver 3arameters
dialog or the 3si\$ar() function. 1hese are factors that are under your control S
you (or the olver) will decide what values they should have.
=. 5efine uncertain variable cells (such as &=), that contain formulas calling the
3- 5istribution functions supplied by Risk olver S for e*ample
3si7niform() and 3si2ormal(). 1hese are factors that are not under your
control.
@. #uild your model, using cell formulas that may depend on the decision
variables, uncertain variables, or both.
M. 0ach cell (such as #<) containing a formula that depends on uncertain
variables (say E&<V=O&=) represents thousands of trial values, generated
during each 'onte (arlo simulation by sampling different values for &= and
computing E&<V=O&=.
:. -n other cells (such as (<), define the summary statistics you want, using
functions such as 3si'ean(#<) or 3sitd5ev(#<). >ou may use formulas to
compute further values based on these summary statistics.
D. 5efine your ob)ective and constraints for optimi4ation. 1hese may be cell
formulas that depend only on the decision variables, depend on the uncertain
variables through 3- tatistics functions, or depend on both.
Solvin+ a Simulation O'timi*ation Model
olving a simulation optimi4ation model using 3remium olver and Risk olver is
also straightforward. /ollow these steps:
<. &ctivate -nteractive imulation by clicking the light bulb button on the Risk
olver Ribbon or toolbar.
=. elect 1ools 3remium olver to display the olver 3arameters dialog, and
click the olve button.
imulation optimi4ation is a powerful, general framework for finding +best solutions,+
but it is computationally very e*pensive, and there are limits on the si4e and
comple*ity of your model (number of decision variables, uncertain variables,
constraints, and total formulas) if you want to find a solution in a reasonable amount
of time. /rontline ystems is already delivering the highest performance software for
simulation optimi4ation in 0*cel available today -- but we.re taking this capability
much further in the futureN (ontact us if you.d like to learn more.