My name is Ram Rachum, and I'm a Python software developer based in Israel.

This is my personal blog. I write about technology, Python, programming and a bunch of other things.

This is my personal blog. I write about technology, Python, programming and a bunch of other things.

Text

When I was a few years younger, I would ride buses a lot when I wanted to get from one city to another. I would also hitchhike a lot, sometimes in order to save money and sometimes because I was travelling when the buses were no longer operating.

While waiting, bored and desperate, on the side of the road, I would sometimes try to mathematically evaluate how long I have to wait before my ride comes, whether it be a bus or that sweet, blessed car that would finally make me feel more like a human being who other people care about and less like I’m a homeless person who was going to die dirty, sweaty and hungry on the side of the road.

Through some modest mathematical thinking, I found that the results were quite surprising. Let me show them to you.

First, imagine you’re waiting for a bus. Say that this bus has an hourly schedule, i.e. a bus comes to the stop that you’re waiting in once an hour. Now, you’re not sure *when* it’ll come, whether it’s every round hour, or on the :30 minutes mark, or at any other mark. So you’re just waiting.

The first question is: **How long will you have to wait for the bus, on average?**

The answer is quite straightforward: 30 minutes. It’s easy to understand why: The worst-case scenario is that the bus just passed, so you’ll have 60 minutes to wait until the next one. The best-case scenario is that the bus is going to pass just now, meaning 0 minutes. Since all the options in between are linear, the average of the two is the average of the whole thing.

Now, here’s a more difficult question. You’ve just arrived at the bus stop, and as we agreed before, you have an average of 30 minutes to wait. You’ve waited around for 10 minutes, and unfortunately a bus did not come. The question is: **How long, on average, do you have to wait now?** Feel free to give this some thought before continuing to the next paragraph.

Some people might instinctively answer 20 minutes, since you had 30 minutes to wait before, and 10 minutes have passed, so 30 minus 10 is 20 minutes. But unfortunately that’s wrong. Consider this: Your worst-case scenario is now 50 additional minutes until the bus comes, and the best-case scenario is 0 additional minutes. The average of 50 and 0 is 25. So the answer is 25 minutes. How come? How come only 5 minutes passed in “average time” while 10 minutes passed in reality? Simple, in those 10 minutes that passed, new information came to light that was not available when we first made that 30 minutes evaluation. That information is: The bus did *not* come in the first 10 minutes of our wait. That information tipped the scale against us (as we would have obviously preferred the bus to come in those 10 minutes) and changed our expectation of the bus’ arrival accordingly.

In fact, for every minute of real time that passes, only 30 seconds of “average time” pass. Pretty neat, ah? Well, I guess it’s neater for the person contemplating this fact in an air-conditioned room than for the person waiting on the side of the road :)

(By the way, this concept of “average time you have to wait” is called expected value in probability theory, and it’s a very interesting topic in its own right.)

Now for the next question, concerning hitchhiking.

Imagine that you’re hitchhiking in your favorite hitchhiking spot. You know from hard-earned experience, that the average time it takes to catch a ride in this spot is 30 minutes. You’ve established that from years of hitchhiking in that spot.

And let’s make the simplifying assumption that your chances of catching a ride are not dependent on the time of the day, nor on your visible weariness. (Assumptions that are ultimately wrong, but hey, we’re in mathland.)

So you’ve been standing there, waving your thumb for 10 minutes, and no driver was gracious enough to stop and give you a ride. And you ask yourself: **How long, on average, will I have to keep waiting until someone gives me a ride?**

The answer is definitely not 25 minutes like in the case of the bus, and it’s not 20 minutes either. The answer is 30 minutes.

That’s right. The amount of time you have to wait is exactly the same amount of time you had when you first got there. At first, this result seems confusing. But think about it: What have you gained standing there on the side of the road, except desperation and, depending on the weather, a splash of mud from a passing car? Do you think that just because you spent 10 minutes of your life standing there, you are now more likely to catch a ride? No, these 10 minutes you spent hoping someone would pick you up were a bet, and you lost. Your situation now is identical to your situation as you just arrived at the spot: You’re hoping someone would pick you up.

The term used by mathematicians for situations like these is Exponential Distribution. It’s interesting to see the non-trivial equations that are all a result of that one simple assumption, that your chances of catching a ride in a given amount of time are identical regardless of how long you’ve been waiting.

Happy hitchhiking!

All content in this website is copyright © 1986-2011 Ram Rachum.

This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License, with attribution to "Ram Rachum at ram.rachum.com" including link to ram.rachum.com.

To view a copy of this license, visit: http://creativecommons.org/licenses/by-sa/3.0/

This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License, with attribution to "Ram Rachum at ram.rachum.com" including link to ram.rachum.com.

To view a copy of this license, visit: http://creativecommons.org/licenses/by-sa/3.0/