In Raye’s family, there have been some funny coincidences. Many of you are likely familiar with the “birthday problem” — it says that even among a pretty small group, the odds that two people share a birthday are surprisingly high. Specifically, in a group of 23, the odds are 50-50. But in Raye’s case, among an extended family of 23 people,threepairs of people share birthdays. What are the odds of that? Moreover, all these pairs are on one side of the family, a group of only 14 people. What are the odds ofthat?

So, this blog post is a long story... the above is this weeks Riddler Express. I initially read that as 'three people share a birthday', and that, it turns out this is actually surprisingly tricky (certainly much harder than the actual problem... all the below is written to answer that puzzle, but don't worry, it has a happy ending...

Let's start with the 'classic' birthday problem first. In this case, there are only two options - either at least two people share the same birthday, or no-one does. The probability that no-one shares the same birthday is 1*(364/365)*(363/365)*...(365-22)/365 = (365!/342!)/365^2 = 0.4927. The first person can have any birthday, and then the second person can have any of the 364 other birthdays, and so on...

It doesn't seem there's an equally neat solution for the case where we want three people to share a birthday. You can get a pretty good rough and ready estimate by assuming all the triples independently have a probability of 1/365^2 to share a birthday, and then counting the number of sets of three people.

There are 23 C 3 = 23 * 22 * 21 / 3! = 1771 sets of 3 people in a group of 23 people. Assuming independence, the chances that none of them share the same birthday is thus:

((365^2-1)/(365^2))^1771 = 0.9867

and the chances that there is some triple with the same birthday would be 0.0143 (or about 1.4%).

However, that independence assumption is potentially quite far off - a group where three people share the same birthday is way more likely than average to have another group of three people that share the same birthday, so this actually significantly underestimates the true odds. Before we calculate the true odds, let's just have a quick visualisation of what they are (very inefficient simulation code here).

So 0.0143 probably wasn't too far off - it looks like the true odds are something like 0.013. How can we work that out exactly?

Well, if there are not 3 people with the same birthday, then either no-one shares a birthday (we already know how to work out the probability of that), or there are only pairs of people that share a birthday.

The probability there is exactly one pair that shares a birthday is relatively straightforward. The pair can be any of the 23C2 possible pairs, they can have any one of the 365 birthdays, and then everyone else must have a different birthday, so thats:

(23C2*365*364*...*343)/365^23 = 0.111

There doesn't seem to be a nice closed form for this, so we just work out the probabilities that there are exactly 2 pairs, exactly 3 pairs, etc, and add them together - that's what the python codes does below (it's done step by step to avoid problems with floating point precision). The probability that there are 3 or more people with the same birthday is 1 - the sum of all of these, which comes to 1-0.987 =

Let's start with the 'classic' birthday problem first. In this case, there are only two options - either at least two people share the same birthday, or no-one does. The probability that no-one shares the same birthday is 1*(364/365)*(363/365)*...(365-22)/365 = (365!/342!)/365^2 = 0.4927. The first person can have any birthday, and then the second person can have any of the 364 other birthdays, and so on...

It doesn't seem there's an equally neat solution for the case where we want three people to share a birthday. You can get a pretty good rough and ready estimate by assuming all the triples independently have a probability of 1/365^2 to share a birthday, and then counting the number of sets of three people.

There are 23 C 3 = 23 * 22 * 21 / 3! = 1771 sets of 3 people in a group of 23 people. Assuming independence, the chances that none of them share the same birthday is thus:

((365^2-1)/(365^2))^1771 = 0.9867

and the chances that there is some triple with the same birthday would be 0.0143 (or about 1.4%).

However, that independence assumption is potentially quite far off - a group where three people share the same birthday is way more likely than average to have another group of three people that share the same birthday, so this actually significantly underestimates the true odds. Before we calculate the true odds, let's just have a quick visualisation of what they are (very inefficient simulation code here).

So 0.0143 probably wasn't too far off - it looks like the true odds are something like 0.013. How can we work that out exactly?

Well, if there are not 3 people with the same birthday, then either no-one shares a birthday (we already know how to work out the probability of that), or there are only pairs of people that share a birthday.

The probability there is exactly one pair that shares a birthday is relatively straightforward. The pair can be any of the 23C2 possible pairs, they can have any one of the 365 birthdays, and then everyone else must have a different birthday, so thats:

(23C2*365*364*...*343)/365^23 = 0.111

There doesn't seem to be a nice closed form for this, so we just work out the probabilities that there are exactly 2 pairs, exactly 3 pairs, etc, and add them together - that's what the python codes does below (it's done step by step to avoid problems with floating point precision). The probability that there are 3 or more people with the same birthday is 1 - the sum of all of these, which comes to 1-0.987 =

**0.0127**(so our independence assumption wasn't too bad after all). The Riddler also asked* for the probability of 3 matches in a group of 14 people, which we can now work out is**0.00266**. While we're here, we should probably answer the obvious extension question - it looks from the graph like there have to be 88 people in the room for the probability of 3 or more matches to be > 50%, and this turns out to be correct - with 87 people the probability of 3 or more sharing a birthday is 0.4995, and with 88, it's 0.511.A function to find the probability that exactly k pairs share birthday in a group of n people

As I mentioned at the start, that isn't actually the question in the Riddler - the actual question was what is the probability that three *pairs* of people share a birthday. Luckily, the function above, which was written as part of the answer to the much harder question, answers this, so it only took a few minutes to get the answer to the actual question. The probability of exactly three pairs sharing a birthday in 23 people is 0.018. The probability of either 3 or more pairs sharing a birthday or three people sharing a birthday is 0.033. For 14 people, these numbers are 0.00079 and 0.0034 respectively.

So in any group of 14 people, there's a probability of about 0.3% of there being a birthday coincidence at least as unlikely as Raye's. It's hard for me to estimate the readership of a page at 538, but 1382 people entered the 'Battle for Riddler Nation' a few weeks ago. if each of those people picked a group of 14 random friends, you'd expect 5 of them to find 3 or more birthday matches. Given that each person is definitely in more than one group of 14 or more people, it starts to become even more common. In fact, I'm willing to bet that at least one person who has responded to the puzzle included details of a birthday coincidence that was at least as surprising, if not more so, than Raye's.

So in any group of 14 people, there's a probability of about 0.3% of there being a birthday coincidence at least as unlikely as Raye's. It's hard for me to estimate the readership of a page at 538, but 1382 people entered the 'Battle for Riddler Nation' a few weeks ago. if each of those people picked a group of 14 random friends, you'd expect 5 of them to find 3 or more birthday matches. Given that each person is definitely in more than one group of 14 or more people, it starts to become even more common. In fact, I'm willing to bet that at least one person who has responded to the puzzle included details of a birthday coincidence that was at least as surprising, if not more so, than Raye's.