Thought Toys · Computation & information · Exhibit 125
Two crews answer the same emergency calls, one at a time, in the order they come in. The fast crew finishes a call a minute quicker on average, but its trips vary: some take five minutes, some take forty. The steady crew takes ten minutes, every time. Watch who your call waits for. On a busy day the slower crew is on its way to you sooner, and the reason is not how fast it drives. It is how much its trips vary.
The same calls, two crews ● the fast crew ● the steady crew ○ the average so far
—
—
Each lane is one crew. The calls come in at random, and both crews get exactly the same calls at exactly the same moments. A crew that is free sets out at once. A crew that is busy leaves the call in the pile on the left, and the pile is the waiting line. The bar in each lane is the call the crew is on right now, filling up as the minutes pass. Its length is how long that trip takes. Two states, then: waiting in the pile, or being answered on the bar.
Look at the two kinds of bar. The steady crew's bars are all the same length, ten minutes each. The fast crew's bars are usually shorter, but every so often one is enormous. While that long trip runs, calls pile up behind it, and everyone in the pile pays for it. When a short trip comes along, there is often nobody waiting to cash it in. Short trips are wasted on an empty pile; long trips are charged to a full one. That asymmetry is the whole effect.
The chart underneath turns it into a number. The amber curve is the fast crew's average wait as its trips get more erratic, from all-the-same on the left to wildly varying on the right. The cyan line is the steady crew, which does not move because its spread is fixed at zero. Where the two cross is the tie. At the default pace, 4.8 calls an hour, the tie is at a spread of about 0.73. On this scale a spread of 1 is what you get from trips as random as an exponential clock, so the tie sits a little below that. At this pace, a crew that is a full minute faster per call, but merely exponential, already loses.
Now drag How busy the day is. The tie moves. At the quiet end of the slider, half a call an hour, it sits near a quarter, and even a slightly erratic fast crew loses, though nobody waits long either way. At the flat-out end, 5.5 calls an hour, it moves past 1.5, and the fast crew wins even while quite erratic. The steady crew is the slower one, so it is the first to approach its own wall, the load at which it can never catch up, and near that wall its wait outgrows any multiplier. Busy days protect speed. Quiet days reward steadiness. Neither day forgives spread for free.
The hollow dots are the two crews' running average waits, from the calls answered so far in this session. They wander at first, because a queue remembers: one bad trip poisons the next dozen waits. Press A year of calls, instantly and they settle onto the lines, which is the law doing what a law should. Nobody chose these numbers. They fall out of the arrival rate, the trip length, and the spread, and nothing else.
The rule, exactly. Calls arrive at random at rate λ. One crew serves them in order; a trip lasts a random time with mean m and spread C2 = variance / m2. Write ρ = λm for the share of the time the crew is busy. The mean wait before the crew sets out is
W = ρ m (1 + C2) / 2(1 − ρ)This is the Pollaczek–Khinchine formula (1930, 1932), for the queue that engineers call M/G/1. The load sets the hyperbola; the spread sets the multiplier (1 + C2)/2. A crew whose trips are all the same length (C2 = 0) makes callers wait half as long as an exponential crew (C2 = 1) at the same load, and that exponential case is exhibit 58. Two crews answering the same calls tie where
1 + C2fast = (msteady / mfast)2 · (1 − λmfast) / (1 − λmsteady)The page draws each trip from a gamma distribution with the chosen mean and spread, and a spread of zero means every trip is exactly the mean. The steady crew is fixed at ten minutes and a spread of zero. The slider for the day stops at 5.5 calls an hour, which keeps the steady crew under its wall (ρ = 0.92); past the wall no average exists to print.
Verified in node (improve/verify/125-queue-variance.js, 9 checks, three of them
controls, all before this page existed):
Felix Pollaczek published the formula in 1930 and Aleksandr Khinchine found it again, by a different route, in 1932. The steady case came first: Agner Erlang worked out the wait for calls of a fixed length at the Copenhagen telephone exchange in 1909, two decades before the general law, which is why the constant-service queue still carries his name in the textbooks.
Also in Computation & information: Sorting algorithms →