Section 12 An analytical solution

Returning to the case of 20 people in a non-leap year, we can compute the probability analytically via

\[ P(\mbox{at least two birthdays the same}) = 1 - P(\mbox{all 20 birthdays different}) \]

12.1 Total number of possibilities

To compute \(P(\mbox{all 20 birthdays different})\), first count the total number of possibilities (regardless of whether any birthdays are the same or not):

  • there are 365 possible days for person 1
  • for each possible day for person 1, there are 365 possible days for person 2…
  • so there are \(365 \times 365\) possibilities for persons 1 and 2 combined.

Extending this argument, the total number of possibilities must be \(365 \times 365 \times 365 \times \ldots \times 365\), i.e. \(365^{20}\).

12.2 Number of possibilities where all birthdays are different

  • person 1 can have a birthday on any day;
  • person 2 must have a birthday on a different day: there are 364 possibilities for person 2, and \(365 \times 364\) possibilities for persons 1 and 2 combined;
  • person 3 must have a birthday on different days to persons 1 and 2: there are 363 possibilities.

Extending this argument, the total number of possibilities must be \(365\times 364 \times 363 \times \ldots \times 346\).

Exercise 12.1 Using the analytical solution.

  • Compute the probability that at least two birthdays are the same
    • use the : to create a sequence of integers
    • use the prod() command to multiply the elements of a vector together
  • Compare your answer with the Monte Carlo estimate.