In Lectures 8 to 11, every parameter of a model was known: durations, demands and distances were fixed numbers. In practice, many of them are uncertain. This notebook describes the setting of the simulation part of the course, where the inputs of a model are random, and shows with the flaw of averages why we cannot simply replace each random input by its average. The probability concepts it uses are summarized in Variability (Recap). The next notebooks cover how to sample random inputs (Sampling a Random Variable) and the two types of simulation (Monte Carlo Simulation and Discrete-Event Simulation).
Learning outcomes
On completion of this notebook, you will be able to:
describe the simulation setting: random inputs , a model and the expected output
explain the four steps of a simulation study
explain the flaw of averages, and recognize when differs from
The Simulation Setting¶
The optimization problems so far had the form subject to , where is the set of feasible decisions: a model computes the output of a decision for some fixed parameters. When some parameters are random, we collect them in a random variable (usually a vector, one component per random parameter), and the output is random as well. A natural goal is then to maximize the expected output:
In the problems of Lectures 12 and 13, can only be computed by simulation: imitating the random behavior of the real system many times on a computer. Lecture 13 is about choosing the decision . In Lecture 12 the decision is fixed, so we drop and study the random output itself: its expectation , and probabilities such as . There are two types of simulation:
Monte Carlo simulation, when is a known function of a fixed number of random inputs, for example the finish time of a project as a function of the durations of its activities;
discrete-event simulation, for processes that are too complex to write down as one function, such as a queue of customers that evolves over time.
Every simulation study goes through the same four steps:
Fit a distribution to historical data for each random input, for example a lognormal distribution for activity durations. This is part of the statistics part of the course; Canvas has Python code that finds the best-fitting distribution for a dataset. In these notes, the distributions are given.
Sample realizations of from the fitted distribution, so that they are in line with the real-life data (Sampling a Random Variable).
Process every sample in the model, giving the output samples .
Analyze the output samples statistically, for example by averaging them to estimate and computing a confidence interval.
Why fit a distribution in step 1, instead of reusing the historical data directly (called bootstrapping)? A fitted distribution gives an unlimited stream of new, realistic samples. Reusing the same limited history risks overfitting: once we optimize decisions (Lecture 13), the best decision for the historical data is not necessarily the best one for the future.
The Flaw of Averages¶
Why simulate at all? A tempting shortcut is to replace every random input by its expected value and to compute the output once, as if the inputs were fixed parameters. This shortcut gives the wrong answer, because in general
Assuming that they are equal is a mistake common enough to have its own name: the flaw of averages (Savage, 2012). Savage illustrates it with a drunk walking down the middle of a highway, swaying from side to side. The drunk’s average position is on the middle line, where no car can hit them. But they are rarely at their average position, and one sway into a lane with a car is enough.
Simulation avoids the flaw of averages without much effort: instead of computing once for the average input, it computes for many samples of and averages the outputs. That average estimates itself, not .
Equality does hold when is linear: , by the rules for sums. A maximum, a minimum (sales are the minimum of demand and stock), a threshold or a product of random inputs breaks it. For such a model there is usually no formula for , especially when has many components, and simulation is the way to compute it.
References¶
Koole, G. (2019). An Introduction to Business Analytics. Chapter 5, “Simulation.”
Savage, S. (2012). The Flaw of Averages: Why We Underestimate Risk in the Face of Uncertainty. Wiley.