3 ms·
R has a function for this qbirthday(prob = 0.5, classes = 1e6, coincident = 2) # 1178 You could also just calculate a bunch of the probabilities and find the
by ryanmonroe 9y ago
R has a function for this
qbirthday(prob = 0.5, classes = 1e6, coincident = 2)
# 1178
You could also just calculate a bunch of the probabilities and find the minimum more "maunually"
in.room <- 1000:1500
probs <- sapply(in.room, function(x) prod(((1e6 - (x - 1)):1e6)/1e6))
in.room[which.min(abs(probs - .5))]
# 1178