Skip to content
Tutorials Center
My learning

Topics

Lesson 14 of 38 ยท M/M/1 Queues

Checking M/M/1 with Simulation

Learn how to check queueing formulas with simulation: independent replications, confidence intervals and warm-up deletion, with M/M/1 as the test case.

Closed-form formulas are only as good as their assumptions. When you move to a system with no exact formula, simulation is the tool you reach for. The M/M/1 queue is the perfect practice ground: we know the right answers, so we can learn how to run simulations properly and how much to trust them.

One run is one random number

A simulation gives one sample of a random outcome. Two runs with different random seeds give different averages. To judge how close the estimate is to the truth, we need several independent replications, a mean, and a confidence interval.

Take n replication averages x1, ..., xn with sample mean xฬ„ and sample standard deviation s. A 95% confidence interval is

xฬ„ ยฑ t* ร— s / โˆšn

where t* is the Student t critical value with n - 1 degrees of freedom (about 2.26 for n = 10).

Replications and a confidence interval

We estimate the mean waiting time Wq for ฮป = 0.8 and ฮผ = 1; theory says Wq = ฯ/(ฮผ - ฮป) = 4. Each replication simulates 60,000 customers with a different seed.

Python Replications with a confidence interval

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The interval should contain the theoretical value 4 in about 95 out of 100 such experiments. A wider interval warns you that you need more customers or more replications.

The warm-up problem

A simulation starts with an empty system, but the long-run average describes a system that has been running forever. Early customers see a nearly empty queue, so including them biases the estimate downward. The standard fix is to throw away the first part of each run, the warm-up period.

The effect is largest for short runs and high utilization. Let us measure it with many short replications (400 customers each), with and without deleting the first 200 customers.

Python Warm-up bias

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Both estimates are noisy, but the version that includes the start-up period is lower on average. Deleting the transient helps. High utilization makes the transient longer, which is why simulating near ฯ = 1 takes so many customers.

A practical checklist

  1. Decide what you measure (average wait, tail probability, utilization).
  2. Pick a warm-up by plotting a running average and seeing where it levels off.
  3. Run several independent replications with different seeds.
  4. Report the mean and a confidence interval, not a single number.
  5. Compare with a formula when one exists, to catch bugs.

If your simulation of a case with a known answer disagrees with theory by more than the confidence interval, suspect a bug in the simulation, not in the mathematics.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Why do we run several independent replications?

    Replications give independent estimates whose spread tells us the precision.
  2. 2. What bias does an empty starting state cause?

    Early customers face a short queue, which pulls the average wait down.
  3. 3. Which makes the warm-up period longer?

    Near rho = 1 the queue takes a long time to reach its steady-state behavior.
  4. 4. A 95% confidence interval for Wq is 3.7 to 4.3. What should you conclude about the theory value 4?

    4 lies inside the interval, so there is no evidence of disagreement.

Summary

  • One simulation run is one random sample; use replications and confidence intervals.
  • Delete the warm-up period to avoid start-up bias.
  • Known M/M/1 formulas make a good test for simulation code.
  • Higher utilization needs longer runs.

Next: The M/M/c Model