... and one should include the pigeonhole principle:

pbirthday2 <- function(n, classes = 365) {
    c <- classes # as pbirthday()
    if(n >= 2) {
        if(n > classes) 1 else -expm1(sum(log1p(-(1:(n-1))/classes)))
    } else 0
}

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to