Saturday 24 August 2024

Bayes at the Bus Stop

 I make no claims to be a statistician (though I recently read a textbook* on Bayesian probability from cover to cover) and I apologise for any errors in this post: my excuse, in the words of Dr Johnson, is "Ignorance, madam, pure ignorance".

But having made that caveat, I feel that I think like a Bayesian when I am waiting for my bus home.   If there are a lot of people waiting, I reduce my estimate of my likely wait.  If there are a lot of people waiting, but then the other bus that the stop serves arrives and they all get on it, I raise my estimate.  If I see my bus leaving just before I arrive at the stop, I expect a longer wait.  And so on.

Now, I have always known that there are pitfalls in taking averages.  If I ask random people how long was their last wait for a bus and take the average, assuming they answer accurately I will possibly get a meaningful estimate of waiting times.  But if I ask random people who play golf what was the result of the last shot they played, almost all of them will have holed that shot.  That doesn't mean that almost all golf shots are holed!  Similarly if I ask cricketers what happened to the last ball they faced, most will have got out to it, but that doesn't mean that most cricket balls take a wicket.

But here is a point I have only recently fully appreciated.  What is the average class size in a school?  If a school has 60 students and two classes it might seem that the average is 30 students per class.  Suppose they are divided so that one class contains 35 students and the other 25.  The average still seems to be 30 students per class.  But if I ask every student how many are in their class, 25 will say "25" and 35 will say "35", so that average is actually higher - 30.833 by my calculation.  And arguably this is a much more meaningful figure since it better represents the experience of the students.

OK.  So now suppose that sometimes when I am waiting for my bus a friend meets me by chance at the bus stop, and that, whenever that happens, they afterwards ask me how long my total wait for the bus was on that occasion.  Let's make a few assumptions - buses come every 20 minutes, I arrive randomly at the bus stop so my average wait is uniformly distributed between 0 and 20, and I don't see buses coming or going: they materialise and dematerialise instantly giving me no clue as to how recently the last bus came.  My friend similarly arrives entirely randomly.  And of course we assume that the bus stop and my phone don't display live information about how far away the bus is, which takes all the fun out of waiting for a bus.** 

How long does my friend think my average wait is based on the data they gather?  I should be able to calculate this directly but out of laziness I simulated it in Excel.  Excel tells me (in one typical simulation of 1000 waits) that my average wait was 10.0904 minutes, while my friend's estimate was 13.3478 minutes.  Of course my friend's estimate is larger than my experience because they are more likely to meet me during a long wait than a short one.

So - here's the question.  I am waiting at the bus stop when I see my friend coming to join me.  Should I revise upwards my estimate of my likely wait, since on the occasions I meet my friend my wait is longer?  And how about if I see my friend on the other side of the street, but they don't see me?

I think I know the answer but I will leave you to think about it if you are so inclined.

* Chris Ferris, Bayesian Probability for Babies

** Not that there is any fun in waiting for a bus