The Birthday Problem

In probability theory, the “birthday problem” considers the probability that in a set of n randomly chosen people, some pair of them will have the same birthday.

Image Title


Let k = # of individuals in of room with the same birthday

\[ Pr(k>=1) = 1 - Pr(k=0) \] \[ where Pr(X=0) = \frac{P_k^{365}}{365^{k}}\] \[ Pr(k>=1) =\prod_{i=0}^k (1 - \frac{i}{365})\]




If there are 23 individuals in a room, there is a 50-50 chance two individuals will have the same birthday

k = 23  # number of people in room
p <- numeric(k)  # create numeric vector to store probabilities
for (i in 1:k)      {
            q <- 1 - (0:(i - 1))/365  # 1 - prob(no matches)
            p[i] <- 1 - prod(q)  }
prob <- p[k]
prob
## [1] 0.5072972



Generalized probability that at least 2 individuals will have same birthday in a room of k people

k = 100  # number of people in room
p <- numeric(k)  # create numeric vector to store probabilities
for (i in 1:k)      {
            q <- 1 - (0:(i - 1))/365  # 1 - prob(no matches)
            p[i] <- 1 - prod(q)  }
plot(p, main="Probability at least 2 people have same Birthday", xlab ="Number of People", ylab = "Probability", col="blue")        



The probability of two individuals having the same birthday quickly increases:

  • 50% probability if 23 people in the room
  • Over 80% probability if 35 people in the room
  • Over 99% probability if 57 people in the room



Number.of.People <-c(seq(1,100,1))
Probabilities <- format(p, digits=3)
probs <- cbind(Number.of.People, Probabilities )   
# Output Table
DT::datatable(probs, rownames=FALSE, options = list(autowidth=TRUE, sClass="alignCenter", className = 'dt-Center', pageLength=10))