Simulation
Simulation
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
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
?
Discrete probability distributions
• 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)
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
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.
“Purchase” Demand
D = 29 = 12*29-3*50 = 198 euros
Monthly Payment 80
70
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
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
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
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
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
◆ 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, $
◆ 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 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)
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…
◆ 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
70
60
50
Frequency
40
• The bars indicate the frequencies Frequency
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