# Calculating the number of "birthday days" in the birthday problem

Given 's' students in a room and 'd' days in the calendar year, what is the probability 'P' that there will be 'k' "birthday days"?

i.e., 'k = 1' means that everybody's birthday falls on the same day, 'k = 5' means that exactly 5 days of the year coincide with the birthday of at least one student, and 'k = s' means that everyone's birthday is unique.

Assume d ≥ s. 'k' will range from 1 to 's', and ∑P from k = 1 to k = s will be 1 (in other words, P(k) is a probability mass function).

What I Know So Far:

• The total number of ways for the students to have birthdays is d^s.

• P(1) = d/d^(s) (because there are 'd' days on which all students could all share the exact same birthday).

• P(s) = d!/(d^(s)(d-s)!) (because this is compliment of the solution to the standard birthday problem)

Any help/resources that get me closer to a formula for P(k) are greatly appreciated. Thanks!

Outline: Under the usual assumptions, there are $d^s$ equally likely ways for the students to be assigned birthdays.
We now need to count the "favourables," the number of ways students can be assigned $k$ birthdays. The $k$ days on which Happy Birthday will be sung can be chosen in $\binom{d}{k}$ ways.
Now we multiply $\binom{d}{k}$ by the number of ways students can be assigned birthdays on some specific $k$ days, so that none of the $k$ days is missed. To calculate this, look at the Wikipedia article on Stirling numbers of the Second Kind. We need to count the number of onto functions from an $s$-element set to a $k$-element set. There are also many questions/answers on MSE about the number of onto functions.
• Yes, that;s right. Another way to think of it is that the usual Inclusion/Exclusion expression for the Stirling numbers involves dividing a count by $k!$. For your application, you don't want to divide, so to undo the division built into the computation of Stirling numbers we must multiply $S(s,k)$ by $k!$. Jul 22 '16 at 20:13