Friday, August 24, 2018

a birthday to share

It's well known that, if you have a room with 23 randomly chosen people*, there is a greater-than 50% probability that at least two people share a birthday. If there are 22 or fewer people, then the chances of a shared birthday are less than 50%. Demonstrating this is a simple exercise in first-semester probability.

So I was wondering how many people you need for the probability of at least three people sharing a birthday to be >50%? Or at least four people? Or at least five people? To the best of my knowledge, there's no elegant closed-form expression for the generalized case of n people. But I think I have the answer for three people: 88.



Rather than go through all the arithmetic, I built an Excel file to simulate it. For these purposes, a trial consists of selecting 88 integers from 1 to 365 (with replacement) and determining if there was a number chosen at least three times. A trial is successful if there was an integer chosen at least three times.The success rate is shown in cell A94. One can run the 1000 trials by clicking on any empty cell. The file is here.  No, I didn't pretty it up. It would be easy enough to build it to perform more trials in one run -- in fact, I originally created it to go through 2500 trials. But file-size is a concern. If you want more trials, just run it repeatedly and write down the success rates. The average of the success rates of five runs is the equivalent of the success rate of one run with 5000 trials. Anyway, when I ran this repeatedly, I got success rates above 50% more than half the time. When I modified the file to look at the case where you choose 87 integers, I got success rates above 50% less than half the time.

If any mathy types are reading this, I'd be interested in knowing:
1) Is there an elegant closed-form solution for 3? For n?
2) Assuming so, does it confirm or deny that it takes 88 people?

*Assuming that birthdays are uniformly distributed across the calendar, and ignoring leap year.

2 comments:

  1. the wiki doesn't even address this particular problem:
    https://en.wikipedia.org/wiki/Birthday_problem

    ReplyDelete
    Replies
    1. Someone sent me a formula from a textbook. It was ugly with a bunch of big factorial. I'm not bothering to do the calls. Maybe I should see if the factorial simplify...

      Delete