Abstract

We want to see the probability of 3 or more people sharing the same birthday in a room with a random sample of 23 people

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 - 2))/365  # 1 - prob(no matches)
            p[i] <- 1 - prod(q)  }
prob <- p[k]
prob
## [1] 0.4756953
plot(p, main="Probability at least 3 people have same Birthday", xlab ="Number of People", ylab = "Probability", col="blue")