In case birthday is not equally distributed, R code is as following:
#----------------------Start----------------------
N <- 365*3
m <- 30
# birthday is equally distributed
pbirth_equal <- function(x) {
return(1.0/N)
}
# birthday is normally distributed
pbirth_norm <- function(x) {
mu <- (N+1)/2
#Note:
# 1. In order to avoid too much truncate error: delta need to be less than N/6
# 2. In order to maintain positive sign of sumPi in the following calculation, delta need to be greater than (m-1)/sqrt(2*pi)
delta <- N/6
px <- (x-mu)/delta
pbirth <- 1/sqrt(2*pi)*exp(-px*px/2)
return(pbirth/delta)
}
Pbirthday <- 0
for (i in 1:N) {
Pi <- pbirth_norm(i)
sumPi <- Pi
for (j in 1:(m-1)) {
sumPi <- sumPi * (1-j*Pi)
}
Pbirthday <- Pbirthday + sumPi
}
(1-Pbirthday) # probability output
#----------------------End----------------------
Basically you need to implement your own birthday piror function. If the birthday is normall distributed with mean: (N+1)/2 and standard deviation: N/6, the probability will be 0.478.