### Name: birthday ### Title: Probability of coincidences ### Aliases: qbirthday pbirthday ### Keywords: distribution ### ** Examples require(graphics) ## the standard version qbirthday() ## same 4-digit PIN number qbirthday(classes=10^4) ## 0.9 probability of three coincident birthdays qbirthday(coincident=3, prob=0.9) ## Chance of 4 coincident birthdays in 150 people pbirthday(150,coincident=4) ## 100 coincident birthdays in 1000 people: *very* rare: pbirthday(1000, coincident=100) ## Accuracy compared to exact calculation x1<- sapply(10:100, pbirthday) x2<- 1-sapply(10:100, function(n)prod((365:(365-n+1))/rep(365,n))) par(mfrow=c(2,2)) plot(x1, x2, xlab="approximate", ylab="exact") abline(0,1) plot(x1, x1-x2, xlab="approximate", ylab="error") abline(h=0) plot(x1, x2, log="xy", xlab="approximate", ylab="exact") abline(0,1) plot(1-x1, 1-x2, log="xy", xlab="approximate", ylab="exact") abline(0,1)