0% found this document useful (0 votes)
6 views

Simulation

This document discusses using simulation to model systems with uncertain parameters. It provides an overview of simulation concepts and techniques, including generating random parameters from probability distributions and running multiple replications to account for uncertainty. It also gives an example of using simulation to evaluate the expected costs of different home electricity plans when monthly consumption varies randomly.

Uploaded by

K.P.S Drones
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Simulation

This document discusses using simulation to model systems with uncertain parameters. It provides an overview of simulation concepts and techniques, including generating random parameters from probability distributions and running multiple replications to account for uncertainty. It also gives an example of using simulation to evaluate the expected costs of different home electricity plans when monthly consumption varies randomly.

Uploaded by

K.P.S Drones
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 45

SIMULATION

Data Analysis for Decision Making

Simulating systems

Introduction to simulation
What we need to perform a simulation
Generation of random parameters
Home electricity Monthly Plan - Example
Why Simulation ...?

System

Experiment Experiment
with the with a model
real system of the system

Physical Mathematical
model model

Analytical Simulation
solution
… simulation is the only way

 Difficulty or impossibility of experimenting


with the real system

 Difficulty or impossibility of building a physical


model of the real system

 Difficulty or impossibility of finding an


analytical solution of the mathematical model
Simulation – A useful tool to study lines

https://www.youtube.com/watch?v=od0PdUuzGnE
What we need to perform a simulation
Random numbers
Mathematical model : generator
- Variables to be estimated
- Deterministic parameters
- Random parameters
Random parameters
generator

Computer that repeats


calculations n times

Someone who decides:


- More replications?
- What to do with results
Transforming data in functions
Observed data Standard functions

?
Discrete probability distributions

Distribution Parameters Application

Uniform a, b Multiple events


Bernoulli p Binary events
Binomial p, t Number of items in a batch
Poisson l Times between arrivals
Geometric p # of parts between failures
Continuous probability distributions

Distribution Parameters Application

Uniform a, b Multiples / Random # generators


Normal m, s Multiples
Exponential m Times between arrivals / services
Weibull a, b Times between failures
Beta a1, a2 Times between failures
Lognormal m, s Execution times of tasks
Triangular a, b, c When we have no data
Gamma a, b Execution times of tasks
Generation of discrete random parameters
Use of the Distribution Function F(x)
F(x)
Random 1
numbers
generator
U (0,1)

Value x of the random parameter


Generation of continuous random parameter
Use of the Distribution Function F(x)
F(x)
1
Random
numbers
generator
U (0,1)
0 x

Value x of the random parameter


Simulating systems
 Select the variables to be computed
 Identify the parameters involved in the problem
 Identify relationships between variables and parameters
 Classify parameters: deterministic / random
 Choose probability distributions for random parameters
 For each replication
 Generate random parameters from random numbers (0, 1)
 Compute variables
 Do n replications and compute mean, standard deviation,
standard error and confidence intervals
Risk and Evaluation of Alternatives

◆ Example: Evaluating a Home electricity Monthly Plan

◆ Reward and Risk

◆ Connecting Random Inputs and Random Outputs

◆ Simulating Uncertain Outcomes in Excel

◆ Interpreting Simulation Results: “Short” vs. “Long” Simulations

◆ Using Histograms to Visualize Simulation Results


Making Decisions in Low-
Uncertainty vs. High-
Uncertainty Settings

• Newsvendor example:
• A product (P) sells for price of 12 euros
• The cost of the product is 3 euros
• If an item is unsold, it has to be salvaged at no
value (i.e. sold for 0 euros)

• The decision of how many products to purchase must


be made before the demand that impacts the outcome
(i.e. profit) is known
• At the time of decision taking, the demand D is unknown,

• But can be modeled as a random variable


Modeling Random Variables using Scenarios
◆ Random variables can be modeled using a “scenario” approach
– Each scenario is a value that a random variable can take
– Each scenario has a probability of being realized

100
80
60
40
20
0
0 10 20 30 40 50 60 70 80 90 100

◆ For example, one can use historical data as scenarios for the future demand, with
equal probabilities attached to each demand value observed in the past
Modeling Random Variables using Continuous
Probability Distributions
◆ Or, one can “fit” a probability distribution (for example, a normal distribution)
to historical data and use that distribution to model future demand
Random Demand May Lead to
Random Profit
◆ If the demand is modeled as a random variable, profit  may also
become a random variable

◆ Consider three demand values observed in the past

63

41

29
Random Demand May Lead to
Random Profit
◆ If the demand is modeled as a random variable, profit  may also
become a random variable.

◆ Let’s say we decided to order Q=50 units of product “now”


Random Demand May Lead to
Random Profit
◆ If the demand is modeled as a random variable, profit  may also
become a random variable

“Purchase” Demand
D = 29  = 12*29-3*50 = 198 euros

Q=50 D = 63  = 12*50-3*50 = 450 euros

D = 41  = 12*41-3*50 = 342 euros

◆ A decision leads to a distribution of profits, rather than a certain, fixed profit


value
Example:
Evaluating a Home
Electricity Plan
• You are considering changing your home electricity
payment plan to sabe money on the average monthly
bill.

• Under your current plan, you are paying 0.2 €/KWH


consumed.

• After doing research on other available, you are


interested in evaluating the following one:
• You will pay a flat fee of 30 €/month for up to
200 KWH per month (resulting in a 30/200=
0.15 € per KWH)
• The exceeding KWH Will be paid at 0.27 €/KWH
Example: • Your average monthly consumption is 210
Evaluating a KWH per month, and pay 0.2 € per KWH. Your
monthly average payment is therefore 210 x
Home •
0.2 = 42 €
Under the new plan, if you consume 210
Electricity Plan KWH, you Will pay 30 € (for the first 200 KWH)
+ 10 KWH x 0.27, that is, 32.70 €per month.
• On the other hand, if any given month you
consume less than 200 KWH, let´s say 180
KWH:
• Under the current plan you would pay
120 x .20= 24 €
• Under the New Plan you would pay the
flat fee of 30 €
• Which Plan would you choose?
Consumption
Key “Output” Measure: 90

Monthly Payment 80

70

• As we can see, the final payment depends 60


on the actual monthly consumption.
• You don´t know exactly how this 50

Frequency
consumption Will vary from now on, but
you have the historical data of your past 40 Frequency
consumptions.
• You know that in average you consume 30

210 KWH, with a Standard Deviation of 28


KWH/month 20

• How would you add this information into 10

your decision process?


0

235
115
125
135
145
155
165
175
185
195
205
215
225

245
255
265
275
285
295
More
Bin
Example: Evaluating a Home Electricity Plan: Probability
Distribution
◆ Based on the analysis of your historical data, and after examining the distibution of
this payments, you can model your electricity consumption as a normal random
variable with a mean of 210 KWH and a standard deviation of 28 KWH.

Consumption
90

80

70

60
Frequency

50

40

30

20

10

Bin
Cost

Reward and Risk


400

• In dealing with uncertain outcomes it may be


350
important to be able to calculate performance
measures that can be used to compare decisions, 300
like decisions to choose a new electricity plan
versus staying with the old one 250

Frequency
• When comparing decisions under Frequency
200
uncertainty, we can then use such
performance measures as an objective 150
function
• One such performance measure is “reward” 100

• Expected value of cost or profit are usual 50


indicators of the “attractiveness” of a given
decision 0

Bin
Risk Measure: Standard Deviation of Monthly
Payments Under Old and New Plan
◆ “Risk” may be different for different decision makers
◆ One proxy of Risk is the standard deviation of monthly payments

Monthly Consumption - €/month


400

350

300

250

Frequency
200 Frequency

150

100

50

30
32
34
36
38
40
42
44
46
48
50
52
54
56
58
60
More
Bin
Current Plan New Plan
Risk Measure: Standard Deviation of Monthly
Payments Under Old and New Plan
◆ “Risk” may be different for different decision makers
◆ One proxy of Risk is the standard deviation of monthly payments
◆ Some may be concerned about the likelihood of actual monthly payments
exceeding a certain threshold, e.g., $250 €

Monthly payment
Making Best Decisions in High-Uncertainty
Settings: A Roadmap
Decide upon reward and risk
measures

For each competing decision, use


simulation to estimate reward and risk
measures

Use reward as an objective and risk


measures as constraints to find the best
decision
Risk and Evaluation of Alternatives
◆ Making Decisions in Low-Uncertainty vs. High-Uncertainty Settings

◆ Example: Evaluating a Wireless Data Plan

◆ Reward and Risk

◆ Simulating Uncertain Outcomes in Excel

◆ Interpreting Simulation Results: “Short” vs. “Long” Simulations

◆ Using Histograms to Visualize Simulation Results


Example: Evaluating a Home
Electricity Plan
◆ Your average monthly consumption is 210 KWH per month, and pay 0.2 € per
KWH. Your monthly average payment is therefore 210 x 0.2 = 42 €

◆ Under the new plan, if you consume 210 KWH, you Will pay 30 € (for the first 200
KWH) + 10 KWH x 0.27, that is, 32.70 € per month.

◆ On the other hand, if any given month you consume less than 200 KWH, let´s say
140 KWH:
◆ Under the current plan you would pay 140 x .20= 28 €
◆ Under the New Plan you would pay the flat fee of 30 €
◆ Which Plan would you choose?
We Have a Complete Description of the Random Future
Monthly Payments Under the Old Plan
Probability
Expected Monthly
Payment = 42 €

Monthly payment, $

◆ Let´s asume yhat your monthly consumption is distributed as norms random


variable, with an average of 210 KWH, and a standard deviation of 28 KWH.

◆ So, the expected value of monthly payments under the old plan is 42 €

◆ The standard deviation of monthly payments under the old plan is 5.6 €
What About the Distribution of Monthly Payments
Under the New Plan?

◆ What is the expected monthly payment under the new plan?

◆ What is the standard deviation of the monthly payments under the new plan?
An Algebraic Formula: Monthly Payment for Any
Value of Consumption

◆ We can calculate the monthly payment value P (in €) for any consumption value (=C)

◆ If C is below or at 200, then the monthly payment P is 30 €

◆ If C is above 200, then the monthly payment is 30 + 0.27*(C-200)

◆ We can combine these two cases into a single EXCEL formula:


P = 30 + IF(C>200,0.27*(C-200),0)
An Algebraic Formula: Monthly Payment for Any
Value of Consumption
◆ P = 30 + IF(C>200,0.27*(C-200),0)

◆ C is distributed as a normal random variable with a mean of 210, and a


standard deviation of 28

◆ What is the distribution of P?

◆ What is the expected value of P?

◆ What is the standard deviation of P?


Simulation as an Analytics Tool
◆ Simulation is a tool that uses a probability distribution of the “input” random variable (for ex.
C) to create a distribution of the “output” random variable (for ex. P)

Probability Probability
Distribution of C
Simulation Distribution of P
Simulation as an Analytics Tool
◆ In each iteration of the simulation, a random value of the “input” variable is
generated…

◆ … and the resulting value of the “output” is calculated:


◆ P = 30 + IF(C>200,0.27*(C-200),0)
Simulation as an Analytics Tool
◆ These simulation steps (called “simulation runs”) can be repeated as many
times as necessary to generate the “sample distribution” of “output” values

◆ Once this “sample distribution” of output is generated, it can be analyzed to


determine estimates for the expected value, standard deviation, etc. – and any other
reward and risk measures we choose

◆ Excel can be used for both running the simulation and for the follow-up analysis
Running Simulation in Excel:
Analysis ToolPak
◆ Standard Excel add-in
Installing Analysis ToolPak

3
1
Simulated Consumption Values and Corresponding Monthly
Payment Values: Excel Implementation
Risk and Evaluation of Alternatives
◆ Making Decisions in Low-Uncertainty vs. High-Uncertainty Settings

◆ Example: Evaluating a Wireless Data Plan

◆ Reward and Risk

◆ Connecting Random Inputs and Random Outputs

◆ Simulating Uncertain Outcomes in Excel

◆ Interpreting Simulation Results: “Short” vs. “Long” Simulations

◆ Using Histograms to Visualize Simulation Results


Simulated Consumption Values and Corresponding Monthly
Payment Values (n=10 simulation runs, seed = 123)
Simulated Consumption Values and Corresponding Monthly
Payment Values(n=1000 simulation runs, seed = 123)
Visualizing Simulation Results
Using Histograms
◆ Histograms are often useful for gaining intuition about the random inputs and the
random outputs involved in a simulation
◆ In the data plan example, the random input is the Consumption C, and the random
output is the monthly payment P
Histogram of Simulated Values Consumption
of Consumption C 90

(n=1000, seed = 123) 80

70

60

50

Frequency
40
• The bars indicate the frequencies Frequency

(number of occurrences) for the values 30


of a given consumption range (bin)
20

10

235
115
125
135
145
155
165
175
185
195
205
215
225

245
255
265
275
285
295
More
Bin
Histogram of Simulated Values of Monthly Payment
P (n=1000, seed = 123)
Payments

400

350

300

250
Frequency

200 Frequency
150

100

50

0
30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 More
Bin

◆ The Output (Payments) don´t seem to follow a


normal distribution

You might also like