5 Introduction to Simulation
- Simulation involves using a probability model to artificially recreate a random phenomenon, many times, usually using a computer.
- Given a probability model, we can simulate outcomes, occurrences of events, and values of random variables, according to the specifications of the probability measure which reflects the model assumptions.
- In general, a simulation involves the following steps.
- Set up. Define a probability space, and related random variables and events.
- Simulate. Simulate — according to the assumptions reflected in the probability measure — outcomes, occurrences of events, and values of random variables.
- Summarize. Summarize simulation output in plots and summary statistics (relative frequencies, averages, standard deviations, correlations, etc) to describe and approximate probabilities, distributions, and related characteristics.
- Sensitivity analysis. Investigate how results respond to changes in the assumptions or parameters of the simulation.
- Many random phenomena can be concretely represented in terms of “box models” and “spinners”.
Example 5.1
Let
Example 5.2
Consider the matching problem with
Example 5.3 Consider a version of the meeting problem where Regina and Cady will definitely arrive between noon and 1, but their exact arrival times are uncertain. Rather than dealing with clock time, it is helpful to represent noon as time 0 and measure time as minutes after noon, so that arrival times take values in the continuous interval [0, 60].
Explain how you would construct a spinner and use it to simulate an outcome. Why could we not simulate this situation with a box model?
Example 5.4
In the meeting problem, how could you construct a circular spinner to represent that they are more likely to arrive near 12:30 and less likely to arrive near 12:00 or 1:00? Imagine the spinner needle is still equally likely to point at any value on the circular axis.
- The probability of event
can be approximated by simulating, according to the assumptions corresponding to the probability measure , the random phenomenon a large number of times and computing the relative frequency of .
Example 5.5
Use a four-sided die (or a box or a spinner) and perform by hand 10 repetitions of the simulation in Example Example 5.1. (Yes, really do it.) For each repetition, record the results of the first and second rolls (or draws or spins) and the values of
, where is the event that the first roll is 3.
- Construct a table of the simulated relative frequencies of each possible value
of .
- Construct a table of the simulated relative frequencies of each possible value
pair of .
- Will the results above tend to produce good estimates of the corresponding theoretical values? Why? If not, how could we improve the estimates?
- In practice, many repetitions of a simulation are performed on a computer to approximate what happens in the “long run”.
- However, we often start by carrying out a few repetitions, (1) by hand to help make the process more concrete, or (2) by computer to check that our code is working correctly
Example 5.6
Recall the meeting problem. Describe in detail how, in principle, you could conduct by hand a simulation and use the results to approximate the probability that Regina and Cady arrive with 15 minutes of each other for the following two models. (See Sections 2.4.2 and 2.5.1 of the textbook.)
- Uniform(0, 60), independent arrivals model
- Normal(30, 10), independent arrivals model
- A probability is a theoretical long run relative frequency.
- A probability can be approximated by a relative frequency from a large number of simulated repetitions, but there is some simulation margin of error, due to natural variability in the simulation.
- The margin of error when approximating a single probability based on a simulated relative frequency is roughly on the order
, where is the number of independently simulated values used to calculate the relative frequency. - Use a margin of error of
when approximating many probabilities based on a single simulation.