Re: geometric progression Message #19 Posted by Jim Kimes on 25 June 2004, 8:39 a.m., in response to message #15 by bill platt
OK, my newsletter is mailed so I can get back to the ‘birthday paradox.’ Below is my contribution to the recent spate of programs to solve the birthday paradox. My program appears to be beefy at first glance, but it does a lot of things automatically, including prompts. First, in this problem, what you’re really solving for is the following:
1 ~ [(364/365) * (363/365) * 362/365)…]
So that leaves us with three variables: 365, or what I call ‘max’; number of iterations, which I call ‘group’: and the probability at a certain group count. You would never want to solve for ‘max’ but you have to input it.
This program can possibly be done with fewer steps by taking ‘max’ to the group number power. You can try that; it would be interesting, but I don’t think you’re going to cut down very many steps. I’m not a proficient BASIC programmer but I’m sure a shorter program can be written in either in Virtual or old BASIC. There is no pride of authorship here so have at it. We can all learn.
Here’s the way the program looks on the HP 19BII, using the solver:
1 – (Perm ( X:Y) / (365^Y)) = P where X = universe (365), Y= no. in group (23, and P = target or resultant probability of a matching birthday.
Step Action Explanation for action
01 LBL BDP Label BirthDay Paradox
02 CLRG Clear all registers
03 CF01=GRP Reminder of which variable to solve
04 PROMPT
05 1 Explained in text above
06 STO 3
07 MAX? What is size of universerse?
08 PROMPT
09 STO 2
10 PROB? What is target probability, answer will be in group size
11 PROMPT
12 STO 04
13 GRP? What is group size, answer will be in probability
14 PROMPT
15 STO 05
16 LBL 01 LBL 01 begins the routine to solve for group size
17 1
18 STO +01
19 RCL 02
20 RCL 01
21 ---
22 RCL 02
23 /
24 RCL 03
25 *
26 STO 03
27 1
28 ---
29 CHS
30 STO 06
31 FS? 01 Sets flag to branch to probability routine, otherwise continue
32 GTO 02
33 RCL 04 Recalls target probability to compare with value in Step 30
34 X>Y?
35 GOTO 01 If probability doesn't satisfy, return to LBL 01 & iterate
36 STOP
37 VIEW 01 View the group size since the routine has stopped
38 STOP
39 VIEW 06 View exact probability since it won't exactly = target
40 LBL 02 Starts new routine solvling for Probability
41 RCL 05 Steps 39 & 40 compare the group counter and
42 RCL 01 compares in Step 41
43 X=Y? Here can use X =Y because number in group will be an integer
44 GTO 03 If they equal then branch to Step 44. Read probability
45 GTO 01
46 LBL 03
47 VIEW 06
48 END
|