Every time I walk into an empty bus stop, I feel like I will have to wait for a much longer time until the next bus arrives. Why am I the first passenger to arrive? And, more importantly, how much longer do I have to wait, now that I know that I am the first passenger in the *queue?* Chances are that the last bus left the stop just seconds ago, therefore the stop is empty.

Let’s measure how much time I expect to wait for the next bus to arrive as I observe more or fewer passengers in the stop. First, let’s model the passengers and let’s assume that they arrive independently one after another and that they arrive at a constant rate, meaning that if we count the number of passengers that arrived during any time interval, say, one hour, that number is expected to be the same, even if we count them during the morning or the evening. Ok, maybe those are strong assumptions (particularly assuming a constant rate, since we know there are peak hours) but let’s start with that. Based on those two assumptions, the number of passengers that use the bus stop during a certain time interval can be modelled as a Poisson distribution.

The Poisson distribution is (perhaps the most) frequently used distribution to model stuff that we count, such as the number of emails that a person receives or the number of cars that go through an avenue. It depends on a single parameter, known as the rate, and in our case is the number of passengers that visit the bus stop per minute. To make our calculations easier, let’s assume that the rate is 1 meaning that we expect one passenger arriving at the stop every minute. This does not mean that exactly one passenger arrives at the stop every minute since there is randomness involved and we are quantifying it with the Poisson distribution.

Then, let´s model the buses. To make it really interesting, let’s assume that buses depart from the stop exactly every 20 minutes and that all the passengers get on the bus when it arrives. Since I have no previous information about the last bus when I arrive at the stop, I could wait anything between just a few seconds (if I am lucky and the next bus is just about to arrive) or the whole 20 minutes (if the previous bus has just departed).

Since the buses depart from the stop at fixed intervals then there is no randomness involved there, however, the time elapsed between the last bus departed from the stop and the moment I arrive is random. Every number between 0 and 20 minutes is equally likely to be the instant that I arrive at the bus stop, therefore that number is modelled with a distribution known as a uniform distribution between 0 and 20 minutes.

Now let’s consider a model for the passengers and the buses. If I had no other information when I arrive at the stop, then my waiting time could be anything between 0 and 20 minutes and, on average, I have to wait 10 minutes for the next bus. However, I can actually count the number of passengers waiting at the bus stop and use that information to obtain a better estimate of my waiting time. This is known as a conditional distribution: how much time do I have to wait given that I arrive at the stop and there are some passengers already waiting there? So it is conditional on the fact that I observe a certain number of passengers (or no passengers at all) already waiting at the bus stop.

The distribution of my waiting time, conditional on the fact that there are some passengers waiting at the bus stop is one of those esoteric distributions known as a truncated gamma (and it can be found using the Bayes’ theorem). The number of passengers waiting at the bus stop does provide information about the next bus since before observing the number of passengers waiting at the bus stop, I knew “nothing at all” (hence the uniform distribution) and after observing the number of passengers, my knowledge is modelled using this distribution which is not uniform.

We can compute the expected time I have to wait for the next bus and the results are that the first 15 or so passengers I find in the bus stop actually represent almost a minute I save on my waiting time. Always the more passengers I find, the less time I expect to wait and so I rather find a crowded bus stop!

Roughly speaking, for each passenger at the bus stop, I save one minute. How accurate is this minute that each additional passenger reduces my expected waiting time? Well, I could get some actual data by recording every day I walk to the bus stop, the time I wait for the next bus and the number of passengers I observe at the bus stop, but it would take several weeks to obtain enough observations. Rather, we can run some simulations. Simulate first a random time between 0 and 20 minutes (the time I arrive at the stop since the last bus), and then simulate the number of passengers, that is, a Poisson distribution with a rate equal to the simulated time. Observing and recording data could take years of my time; simulating data takes just a second.

Simulating both distributions (my time and the number of passengers) helps us obtain, rather than just the expected value, intervals which consider the randomness of the problem. Results, after running this procedure several thousand times, show that indeed I expect to save some time for every extra passenger I observe in the bus stop.

If I find zero passengers at the bus stop, 99% of the time I will have to wait more than 15 minutes for the next bus. However, if I arrive at the bus stop and I find 25 or more passengers, then 99% of the time I have to wait less than 6 minutes for the next bus! Rarely, very rarely, I will find an empty stop with the next bus nearby, therefore, I prefer a crowded stop and then I just cross my fingers hoping that the bus is not too crowded too.

Next time I arrive at a bus stop that doesn’t have the “next bus in X minutes” I can simply count the number of passengers waiting at the stop and obtain a fairly good estimate of my expected waiting time.

[Pictures (top to bottom): 1 – adapted from pexels.com – *Black and white traffic red street* by Caio, CC0 1.0; 2 – adapted from commons.wikimedia.org – *October 4th Tube Strike – Crowded Bus Stand *by CGP Grey, CC-BY 2.0; 6 – adapted from Flickr.com* – waiting at the bus stop* by renee_mcgurk, CC-BY 2.0; other pictures by Chalkdust]

Pingback: Something we all do, but never do math about – Philatopia