Post Reply 
(42S/DM42/Free42/Plus42) Birthday Probability Function
02-10-2023, 04:10 AM
Post: #1
(42S/DM42/Free42/Plus42) Birthday Probability Function
DM42, Free42, HP 42S: Birthday Probability Function

P = Π( 1 - m/C, m = 1 to N-1)

C = number of categories (examples: days in a calendar year, minutes in an hour, number of places, etc...)
N = sample population
P = probability that sample population does not share a category (examples: number of people that don't share the same birthday, number of people from a city that are not in the same location, etc...)


Code:
00 { 58-Byte Prgm }
01▸LBL "BDAY"
02 "CATEGORIES?"
03 PROMPT
04 STO 02
05 1
06 STO 01
07 "N?"
08 PROMPT
09 1
10 -
11 STO 03
12▸LBL 00
13 1
14 RCL 03
15 RCL÷ 02
16 -
17 STO× 01
18 DSE 03
19 GTO 00
20 "PROB= "
21 ARCL 01
22 AVIEW
23 RCL 01
24 .END.

Examples:

Probability that 40 people do not share a birthday (assume a 365 day calendar):
CATEGORIES? 365
N? 40

Probability: 0.10877

Probability that 3 cards drawn do not share the same suit:
CATEGORIES? 4 (4 suits in a deck of cards)
N? 3

Probability: 0.37500

Source:
Diaconis, Persi and Brian Skyrms Ten Great Ideas About Chance Princeton University Press: Princeton, New Jersey. 2018. ISBN 978-0-691-19639-8
Visit this user's website Find all posts by this user
Quote this message in a reply
02-11-2023, 09:24 AM
Post: #2
RE: (42S/DM42/Free42/Plus42) Birthday Probability Function
For small values we can also use:
Code:
00 { 9-Byte Prgm }
01 RCL ST Y
02 X<>Y
03 PERM
04 X<>Y
05 LASTX
06 Y↑X
07 ÷
08 END

Examples

365 ENTER
40 R/S

0.10877

4 ENTER
3 R/S

0.37500
Find all posts by this user
Quote this message in a reply
02-11-2023, 05:34 PM
Post: #3
RE: (42S/DM42/Free42/Plus42) Birthday Probability Function
The approximation does very well!
Visit this user's website Find all posts by this user
Quote this message in a reply
02-12-2023, 10:12 AM
Post: #4
RE: (42S/DM42/Free42/Plus42) Birthday Probability Function
It's less of an approximation but uses the formula:

\(
\begin{aligned}
\bar{p}(k)=\frac{_{365}P_{k}}{365^{k}}
\end{aligned}
\)

where \(_{n}P_{k}\) denotes permutation.

What I meant by "small values" is that with the HP-42S we can't go beyond \(k=195\) or we get the error: Out of Range
However, it still works with Free42 due to its extended range.

For an approximation we can use:

\(
\begin{aligned}
\bar{p}(n,k)
&\approx e^{-\frac{k(k-1)}{2n}} \\
&\approx \left(1 - \frac{k}{2n}\right)^{k-1} \\
\end{aligned}
\)

Here we assume that \(k \ll n\).

Example

40 ENTER
39 *
2 /
365 /
CHS
ex

0.11801


1 ENTER
40 ENTER
2 /
365 /
-
39
yx

0.11105
Find all posts by this user
Quote this message in a reply
02-12-2023, 10:39 AM
Post: #5
RE: (42S/DM42/Free42/Plus42) Birthday Probability Function
It also seems to be a recurring topic of this forum:
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)