To me, the thing that makes probability fun is that the results are frequently surprising. We’ve got very strong instincts about how we expect numbers to work. But when you do anything that involves a lot of computations with big numbers, our intuition goes out the window – nothing works the way we expect it to. A great example of that is something called the birthday paradox.

Suppose you’ve got a classroom full of people. What’s the probability that there are two people with the same birthday? Intuitively, most people expect that it’s pretty unlikely. It seems like it shouldn’t be likely – 365 possible birthdays, and 20 or 30 people in a classroom? Very little chance, right?

Let’s look at it, and figure out how to compute the probability.

Interesting probability problems are all about finding out how to put things together. You’re looking at things where there are huge numbers of possible outcomes, and you want to determine the odds of a specific *class* of outcomes. Finding the solutions is all about figuring out how to structure the problem.

A great example of this is something called the birthday paradox. This is a problem with a somewhat surprising outcome. It’s also a problem where finding the right way to structure the problem is has a dramatic result.

Here’s the problem: you’ve got a group of 30 people. What’s the probability that two people out of that group of thirty have the same birthday?

We’ll look at it with some simplifying assumptions. We’ll ignore leap year – so we’ve got 365 possible birthdays. We’ll assume that all birthdays are equally likely – no variation for weekdays/weekends, no variation for seasons, and no holidays, etc. Just 365 equally probable days.

How big is the space? That is, how many different ways are there to assign birthdays to 30 people? It’s 365^{30} or something in the vicinity of 7.4*10^{76}.

To start off, we’ll reverse the problem. It’s easier to structure the problem if we try to ask “What’s the probability that no two people share a birthday”. If P(B) is the probability that no two people share a birthday, then 1-P(B) is the probability that at least two people share a birthday.

So let’s look at a couple of easy cases. Suppose we’ve got two people? What’s the odds that they’ve got the same birthday? 1 in 365: there are 365^{2} possible pairs of birthdays; there are 365 possible pairs. So there’s a probability of 365/365^{2} that the two people have the same birthday. For just two people, it’s pretty easy. In the reverse form, there’s a 364/365 chance that the two people have different birthdays.

What about 3 people? It’s the probability of the first two having different birthdays, *and* the probability of the third person having a different birthday that either of those first two. There are 365 possible birthdays for the third person, and 363 possible days that don’t overlay with the first two. So for N people, the probability of having distinct birthdays is .

At this point, we’ve got a nice recursive definition. Let’s say that is the probability of people having distinct birthdays. Then:

- For 2 people, the probability of distinct birthdays is 364/365. ()
- For N>2 people, the probability of distinct birthdays is

.

Convert that to a closed form, and you get: . For 30 people, that’s

. Work it out, and that’s

0.29 – so the probability of everyone having distinct

birthdays is 29% – which means that the probability of at least

two people in a group of 30 having the same birthday is 71%!

You can see why our intuitions are so bad? We’re talking about something where one factor in the computation is the factorial of 365!

Let’s look a bit further: how many people do you need to have, before there’s a 50% chance of 2 people sharing a birthday? Use the formulae we wrote up above, and it turns out to be 23. Here’s the numbers – remember that this is the reverse probability, the probability of all birthdays being distinct.

1 | 1 |

2 | 0.997260273973 |

3 | 0.991795834115 |

4 | 0.983644087533 |

5 | 0.9728644263 |

6 | 0.959537516351 |

7 | 0.943764296904 |

8 | 0.925664707648 |

9 | 0.905376166111 |

10 | 0.883051822289 |

11 | 0.858858621678 |

12 | 0.832975211162 |

13 | 0.805589724768 |

14 | 0.776897487995 |

15 | 0.747098680236 |

16 | 0.716395994747 |

17 | 0.684992334703 |

18 | 0.653088582128 |

19 | 0.620881473968 |

20 | 0.588561616419 |

21 | 0.556311664835 |

22 | 0.524304692337 |

23 | 0.492702765676 |

24 | 0.461655742085 |

25 | 0.431300296031 |

26 | 0.401759179864 |

27 | 0.373140717737 |

28 | 0.345538527658 |

29 | 0.319031462522 |

30 | 0.293683757281 |

31 | 0.269545366271 |

32 | 0.24665247215 |

33 | 0.225028145824 |

34 | 0.20468313538 |

35 | 0.185616761125 |

36 | 0.16781789362 |

37 | 0.151265991784 |

38 | 0.135932178918 |

39 | 0.121780335633 |

40 | 0.108768190182 |

41 | 0.0968483885183 |

42 | 0.0859695284381 |

43 | 0.0760771443439 |

44 | 0.0671146314486 |

45 | 0.0590241005342 |

46 | 0.0517471566327 |

47 | 0.0452255971667 |

48 | 0.0394020271206 |

49 | 0.0342203906773 |

50 | 0.029626420422 |

With just 23 people, there’s a greater than 50% chance that two people will have the same birthday. By the time you get to just 50 people, there’s a greater than 97% chance that two people have the same birthday!

As an amusing aside, the first time I saw this problem worked through was in an undergraduate discrete probability theory class, with 37 people in the class, and *no* duplicate birthdays!

Now – remember at the beginning, I said that the trick to working probability problems is all about how you formulate the problem. There’s a much, much better way to formulate this.

Think of the assignment of birthdays as a function from people to birthdays: . The number of ways of assigning birthdays to people is the size of the set of functions from people to birthdays. How many possible functions are there? . is the number of days in the year – 365, and is the number of people in the group.

The set of assignments to unique birthdays is the number of *injective* functions. (An injective function is a function where .) How many injective functions are there? .

The probability of all birthdays being unique is the size of the set of injective functions divided by the size of the set of all assignments: .

So we’ve got the exact same result – but it’s a whole lot easier in term of the discrete functions!