Skip to content
Prev 157450 / 398506 Next

birthday problem (factorial limit)

On Sun, 28 Sep 2008, J?rg Gro? wrote:

            
You might want to look at the pbirthday() and qbirthday() functions and 
the examples on their help page. The function implements Diaconis & 
Mosteller's approximation, which works for different values of two as well 
as of n and 365.  One of the examples compares to the exact calculation, 
which it computes as x2<- 1-sapply(10:100, 
function(n)prod((365:(365-n+1))/rep(365,n)))

This is obviously slow compared to the formula with factorials, but it 
does only take two milliseconds on my laptop, so it's not *that* slow. The 
phrase "premature optimization" springs to mind.


 	-thomas