# Birthdayproblem

#### What is the Birthday Problem?

The original birthday problem, also known as the birthday paradox, asks how many people need to be in a room to have a 50% chance that at least two have the same birthday. Since this number is lower than what our intuition tells us, it is sometimes also considered a paradox.

Generalizing this problem, it is about a set of $D$ objects (e.g. days of the year) from which we draw $N$ samples uniformly at random with replacement (e.g. birthdays) to determine the probability $\bar{P}$ that all samples are unique. This can be calculated with

$$\bar{P}(D, N) = \frac{(D)_N}{D^N}$$

where $(D)_N$ $=$ $D$ $*$ $(D-1)$ $*$ $(D-2)$ $*$ $...$ $*$ $(D - N + 1)$ is the number of ways $N$ different items can be chosen from $D$ and $D^N$ is the number of ways any $N$ items can be chosen among $D$ (assuming the silent, potentially incorrect, assumption that all items are uniformly distributed in $D$). The probability $P$ of the existence of non-unique samples is then the complement $P = 1 - \bar{P}$.

Can you guess the answer to the original birthday problem? Go ahead and put your guess to test below!

#### Generalized Birthday Problem Calculator

Use the calculator below to calculate either $P$ (from $D$ and $N$) or $N$ (given $D$ and $P$). The answers are calculated by means of four methods. When calculating $P$, three different methods are used by default whereas only one is available for calculating $N$. The trivial method is used whenever trivial problem instances are encountered. When calculating $N$, the results are ceiled since no fraction of a sample may be taken. The result therefore reflects the needed size of $N$ to have a probability, equal to or higher, than the input $P$.

Some limitations exist and a single method has at most 1 second to solve a problem instance. The size of the input is also limited. In case of a high load, the server may choose to deny requests temporarily.

accepted

accepted

Resulting input data:

\begin{align*} \rule[-8px]{0pt}{30px} D &= 365\\[-4px] \rule[-8px]{0pt}{30px} N &= 23 \end{align*}

accepted

accepted

Resulting input data:

\begin{align*} \rule[-8px]{0pt}{30px} D &= 365\\[-4px] \rule[-8px]{0pt}{30px} P &= 0.5 \end{align*}

Read more about the birthday problem and the different ways to solve it at Wikipedia.

Check out the source code for the Python solver used in the backend of this app at Github.

Check out the source code of the sister project solver written in Kotlin at Github.