
pbirthday
computes the probability of a coincidence and
qbirthday
computes the smallest number of observations needed
to have at least a specified probability of coincidence.qbirthday(prob = 0.5, classes = 365, coincident = 2)
pbirthday(n, classes = 365, coincident = 2)
prob
that k
or more of them have the same one out of
classes
equiprobable labels.
coincident > 2
. The
approximation is very good for moderate values of prob
but less
good for very small probabilities.require(graphics)
## the standard version
qbirthday() # 23
## probability of > 2 people with the same birthday
pbirthday(23, coincident = 3)
## examples from Diaconis & Mosteller p. 858.
## 'coincidence' is that husband, wife, daughter all born on the 16th
qbirthday(classes = 30, coincident = 3) # approximately 18
qbirthday(coincident = 4) # exact value 187
qbirthday(coincident = 10) # exact value 1181
## same 4-digit PIN number
qbirthday(classes = 10^4)
## 0.9 probability of three or more coincident birthdays
qbirthday(coincident = 3, prob = 0.9)
## Chance of 4 or more coincident birthdays in 150 people
pbirthday(150, coincident = 4)
## 100 or more coincident birthdays in 1000 people: very rare
pbirthday(1000, coincident = 100)
Run the code above in your browser using DataLab