Re: computing chances Message #2 Posted by Eric Smith on 14 Apr 2006, 2:59 p.m., in response to message #1 by Bram
This is known as the "birthday problem" or "birthday paradox", though in my opinion there's no paradox involved.
The probability that two people out of n share the same date is 1 minus the probability that they each have a unique date.
Disregarding leap days, for n people, the probability of all having unique dates is 365Cn/365^n.
Here is an untested program for the HP-41, run with n in X:
LBL BP
1
LBL 01
366
RCL ST Z
-
*
365
/
DSE ST Y
GTO 01
1
X<>Y
-
END
The program starts with a probability of 1, uses an index variable i (on the stack) which counts down from n to 1, and at each step multiplies by (366-i)/365. This results in the probability of no match; the result is then subtracted from 1 to get the probability of a match.
A similar program (also untested) should work on most other RPN calculators by storing the iteration variable in a numbered register rather than on the stack:
LBL B
STO 0
1
LBL 1
366
RCL 0
-
*
365
/
DSZ 0
GTO 1
1
X<>Y
-
R/S
|