Consider that there are 6 buses in an hour. The time between the arrival of the next bus is called headway. If there are evenly spaced out, the headway will be 10,10,10,10,10,10 minutes. But in a city with unpredictable traffic, the arrival time is often disturbed. What will be the perceived performance in those situation? For example, if the only second bus is delayed by 5 minutes, the headway will be 10,15,5,10,10,10. Or consider a more extreme case where the last three bus bunches together so that after a long gap, they all arrive together within a minutes. That gives 10,10,10,28,1,1. If we just takes the arithmetic mean, it will be 10 in all cases. This number of course does not describe that disturbance it causes. Instead we will calculate the expected wait time over the entire period of time.

Define
as the wait time when a person arrive the station at time t. The
chart looks like a sawtooth. It is highest when the passenger arrive just after a bus has left, and it will be 0 when the passenger arrive . Here
is when bus i arrives.,
is the headway to the next bus and
is the sum of
.
The expected wait time is given by this formula

is the probability density function of people arrive at time t. We assume people come uniformly. So
is simply
.



In general communication, it is often more natural to talk about frequency than expected wait time. For example we often say the bus arrive every 10 minutes. But it requires a little bit of math to translate it to 5 minutes of expected wait time. Since the expected wait time is just half of the headway, we can multiple the formula above by to get a effective frequency. We can implement a simple function to calculate the effective frequency below.
>>> def effective_frequency(times):
... h2 = sum(t*t for t in times)
... T = sum(times)
... return float(h2)/T
...
>>> effective_frequency([10,10,10,10,10,10])
10.0
>>> effective_frequency([10,15,5,10,10,10])
10.833333333333334
>>> effective_frequency([10,10,10,28,1,1])
18.1
As expected the last example give a much worst effective frequency 18.1 minutes than the baseline of 10 minutes.
Relation with Variance
It is interesting to study the relationship between expected wait time and the variance of the headway. This is given by the formula.



where 
or
= 2 × Expected Wait Time = effective frequency
There is a very nice interpretation of effective frequency. First of all it is smallest when
is 0. That is when the headway are evenly distributed, it will achieve the optimal frequency μ. Secondly effective frequency is larger than μ by
. So the variance can be interpret as the penalty above the baseline frequency. In order to minimize wait time, it is necessary to minimize variance.
One implication is how to mitigate missed run. If it is necessary to skip a bus run due to equipment break down or availability of drivers, it is better to redistribute the remaining run evenly than to simply miss a run.
>>> effective_frequency([10,20,10,10,10])
13.333333333333334
>>> effective_frequency([12,12,12,12,12])
12.0
Using the formula above, dropping a run with headway 10,20,10,10,10 gives an effective frequency of 13.3. This is worst than if we can redistribute the remain 5 buses to get a frequency of 12.