# Expected number of different birthdays

January 24, 2012 3 Comments

Suppose there are *n* people in a room. It is the well known ‘birthday problem‘ that if *n > 22* the probability of two people sharing the same birthday is greater than 50%, and so it is very likely that there aren’t *n* unique birthdays. However, what is the *expected* number of unique birthdays?

[Let us assume there are *D* days in a year, in order to be more general.]

Actually, the expected number of unique birthdays is very easy to calculate. Let *e(n)* denote the expected number of unique birthdays when there are *n* people.

Choose one of the *n* people. Then either they have a different birthday than everybody else, or they don’t. They have a different birthday than the other *n-1* with probability . Let us write for , and so the probability that they have a different birthday to everybody else is . In this case, the expected number of unique birthdays is *1+e(n-1)*. In the other case, which thus has probability , the expected number is just *e(n-1)*.

Hence,

As *e(1) = 1*, it follows that:

(As one should expect, as *n* tends to infinity this tends to *D*, as it is almost certain that every birthday gets taken)

For instance, with *D = 365,* you should expect about 21 different birthdays when there are 22 people, or 46 different birthdays when there are 50 people. When there are 1000 people, there will be around 341 different birthdays. Perhaps it is quite surprising that you should expect there to be so many (24) unclaimed birthdays with so many people!

Consider the following problem:

Suppose a factory is in a country with the following law: Every worker must work every day, unless it is the birthday of one of the workers. In this case, everybody has the day off. How many people should you hire in order to maximize the expected number of man-days worked every year?

Naturally, if there is only a single person he will certainly work 364 days (*D-1*) a year. If there are two, they are likely to have different birthdays and so each will work 363 days a year (*D-2*), giving a total of 726 days.

The expected number of man days worked will be the number of people, *n*, multiplied by the expected number of non-birthdays. The number of non-birthdays is just *D – e(n)*. Thus we are trying to maximise the following:

Considering *n* as a real number instead of an integer, one can find that the function *W* has a maximum at . Thus the maximum must be around this, and so for all but the smallest D (where the approximation is not valid), the maximum will be either *D-1 *or *D.*

In fact, it is easily seen that *W(D) = W(D-1). *It follows that one should employee either *D* or *D-1* people. Since you will probably have to pay these workers, it is better to go for the *D-1* people.

A simple change of this problem is to consider that for each man-day of work in the factory, you earn *£a*. However, you must pay each worker *£y* per year. Then instead you are maximising the yearly income of:

The derivative of this is . Hence if we must have:

Define so that:

And so we have that:

Let us note that is the ratio between what you pay the worker per year, and what he earns for you per year if he were to work every day. Let us call this ratio *P*.

Note that when *z* is positive, the equation always has a unique solution. The function which takes *z* to *w* is called the ‘Lambert W Function‘. Hence we have that:

It follows that:

As *P* will be small, and in particular less than 1, an approximation of the Lambert W function may be useful. We will use the Taylor Series approximation . Along with the usual log approximation, this gives:

Or, in terms of *P*,

For instance, suppose that I pay my workers £18,000 per year. They generate about £350 in profit for me each day they work. They work every day, except for when one of them has a birthday. By evaluating the *W* function exactly, I find out that the maximum expected profit is when there are around 260 workers. The approximation yields 269 workers. If the profit they generate per day were to be decreased to £75 then the approximation is completely inaccurate. Whilst I should only employee 72 people, the approximation gives over 7,000!

Reblogged this on hrbatanu and commented:

(one)Birthday problem!

This is excellent. But I think it should be 341 unique birthdays when there are 1000 people, not 241.

Thank you very much. Fixed.