If you go down to the bus stop to catch the next bus, how long do you have to wait for the next bus? If buses come every 5 minutes, then you have to wait on average 2.5 minutes for the bus to arrive. But what happens if the buses come unevenly? What happens if the buses get bunched up, so that three buses come within 1 minute between each bus and then it takes 13 minutes for the next bus to arrive? If you just take a simple average of the time between buses:
You will calculate that there's, on average, a 5 minute gap between buses, which again suggests that you have to wait, on average, 2.5 minutes for the bus to arrive. But that doesn't seem right. And it's not.
Let's look more deeply into this problem and see if we can calculate the wait time for the bus more correctly.
Total Wait Time
To build some intuition about the problem, let's consider a bus stop where people arrive every 2 minutes. Buses come to the bus stop at uneven times though.
Depending on when you arrive, you may have to wait longer for the bus. If there's a larger gap between buses, there are more people who have to wait too.
If we want to calculate the total amount of time that people have to wait for the bus, we just have to add up the times from when each person arrives to the time when the bus comes. To make this more clear, we'll draw a little stick figure for a person having to wait one minute for the bus.
In the graph, we can see that over time, the number of people waiting stacks up until a bus comes. It forms a bit of a staircase or triangle. If we add up the number of stick figures in the graph, we can see that there are 14 stick figures, so people waited for a total of 14 minutes for the bus. Over the time period, there were 6 people who came to the bus stop, so the average amount of time each person had to wait was
Now that we have some intuition about calculating bus wait times, let's try generalizing this approach.
Generalization
Every bus stop has people arriving at different times, so to generalize over them, let's assume that people arrive at the bus stop at a constant rate . As people arrive, they wait for the bus until it arrives. When you graph this, you get a lot of right angle triangles. The triangles have a slope that matches the arrival rate of passengers.
The total time that people spend waiting for buses is the area under the triangles. We can calculate the dimensions of the triangles using .
Knowing the dimensions of the triangles, we can then calculate the area of the triangles.
Or if we want to generalize this further for a bunch of buses where we know the time duration between each bus:
Knowing the total wait time that all people wait for their bus, we can just divide the total wait time by the number of people to get the average wait time per person.
Or if we generalize things to a bunch of buses where we know the time duration between each bus:
Notice that the average wait time does not involve the arrival rate of new people at the bus stop .
So now that we have a way of calculating average wait times for a bus, let's look again at the problem posed in the introduction. How long do you have to wait for a bus if the buses are bunched up and the spacing between three buses is 13 minutes, 1 minute, and 1 minute?
That's much longer than the 2.5 minutes that we calculated using an incorrect simple approach. If buses are severely bunched up, you will have to wait more than 2x longer for a bus than if the buses were evenly spaced.
Alternate Formulation
To check if our formulation is correct, we can try calculating the average wait time for buses a different way and see if we end up with the same formula.
Suppose that during a certain period of time, buses can come at different times. You can arrive at any point during that time period.
If we want to create a graph of how long you have to wait at the bus stop, it's pretty easy. The wait time is equal to the time until the next bus arrives. So if you happen to arrive 4 minutes before the next bus, then you'll have to wait 4 minutes. If you arrive 2 minutes before the next bus, you'll have to wait 2 minutes.
You'll notice that the graph of wait times creates a similar set of triangles to the graphs we calculated in our previous formulation.
Now that we have a graph of how long we would need to wait depending on when we arrive, we can calculate the average wait time. We can do that using some calculus.
Integrating over these triangles is the same as taking the area of the triangles. So according to this formulation, the average wait time for a bus results in the same expression as what we determined from the other formulation.
Conclusion
As we can see, calculating how long you have to wait for a bus does take some care, but the resulting math isn't too burdensome.