Activity: Control Variates for the Airport
Advanced Monte Carlo Activities
We change this model together: the instructor types the code, and you type along. Before each run, write down a prediction; then run and check it.
The situation. At the airport checkpoint of the event modeling activities, passengers arrive with exponential times between arrivals with a mean of 2 minutes. One inspector checks their identification in a triangular time with minimum 0.75, mode 1.5, and maximum 3 minutes, and 93% of them pass. We simulate 30 days of 10 hours to estimate the expected time in the system. The manager wants a narrower confidence interval, without simulating more days. Use control variates: let the replication averages of the inputs, whose means we know, correct the estimate.
Setup. Get the starter file AirportControlVariates.kt from the code/ folder beside this activity. Put it in src/main/kotlin/student/activities in your KSL project, the package the file declares; create the folder if you do not have it. It holds the checkpoint model, AirportCheckpoint, whose random variables and time in the system are public. Run its main: it reports the usual half-width summary, and the two parts marked TODO are what we write.
1. Predict
Run. Write down the average and the half-width of
System Time.In one replication, the average time between arrivals happened to be above 2 minutes. Would you expect that day’s average time in the system to be above or below the overall average? Answer the same question for a day whose average inspection time was above its mean. What is that mean?
Which of the two inputs do you expect to explain more of the variation in the time in the system from day to day?
2. Two controls
TODO 1. We make a
ControlVariateDataCollectorfor the model, add the time in the system as its response, and add the two random variables as controls, each with its mean. TODO 2. After the simulation, we get the collector’s data for the response withcollectedData(), regress it on the controls withregressionResults(), and print the results. Run. Do the signs of the two coefficients agree with 1b?The control variate estimate is the intercept. Compare it and its interval with the average and the interval of 1a. By what factor did the half-width shrink?
How many days would we have to simulate, without controls, to get the same half-width?
What fraction of the day-to-day variation in the time in the system do the two controls explain?
3. Choosing controls
Predict, then comment out the time between arrivals as a control and run with the inspection time alone. Compare the half-width with 1a and 2b.
Now use the time between arrivals alone. Compare again. Explain the difference between the two controls.
Predict, then add
passRVas a third control, with its mean, alongside the other two. What happens to the half-width, and why?What makes a good control?
4. More replications
Go back to the two controls of part 2, and set
numRepsto 100. Compare the half-width with controls and without them. How many replications without controls would give the half-width with controls?The book recommends batching the replications when there are 100 or more. Pass the number of batches, 20, to
collectedData()after the response’s name, and run. How much do the estimate and its interval change? What does batching buy, and what does it cost?