computing chances « Next Oldest | Next Newest »

 ▼ Bram Member Posts: 182 Threads: 17 Joined: Oct 2005 04-14-2006, 02:21 PM (just a real life story, slightly to do with calculators; you may like it) Once a year the "nationale wetenschapsquiz" (science quiz) is being held in the Netherlands. It consists of 20 questions that can be answered by knowing, reasoning or guessing. Every year in December the questions and answers are discussed in a television broadcast. Back in the year 2000 question nr.11 was about 26 people (in a café, but that part is not relevant to know): "what is the chance that 2 of these people have their anniversary on the same date?" You could choose from 30, 60 or 80 percent. After some heated discussions about this question between several colleagues of mine, I simply reasoned the answer out. After this it was a matter of calculating the formula, were it not that most calcs cannot do this in one go. Now my questions are: What is the answer and how did you compute it on which HP calc? Bram ▼ Eric Smith Posting Freak Posts: 2,309 Threads: 116 Joined: Jun 2005 04-14-2006, 02:59 PM 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 ``` ▼ Gerson W. Barbosa Posting Freak Posts: 2,761 Threads: 100 Joined: Jul 2005 04-14-2006, 09:37 PM Quote: the probability of all having unique dates is 365Cn/365^n. Shouldn't this be 365Pn/365^n? 1 - 365Pn/365^n = 0.598240820 or 59.8% (for n=26), in accordance with your (tested) HP-41 program. ▼ Eric Smith Posting Freak Posts: 2,309 Threads: 116 Joined: Jun 2005 04-16-2006, 03:30 PM Quote: Shouldn't this be 365Pn/365^n? Yes, the "C" was a misteak. Bram Member Posts: 182 Threads: 17 Joined: Oct 2005 04-16-2006, 01:25 PM Thanks Eric, for your contribution. My comments were already formulated (the last part may be the paradox you mentioned): To start with, the heated discussions were about the precise meaning of the question. Was or wasn't it allowed to have a date with more than 2 anniversaries? Was or wasn't it allowed to have (more than) 2 couples of anniversaries? To my opinion the question means in normal every day language that we are interested in knowing the chances of an occurrence that at least two people celebrate on the same day. I came to that conclusion (and to a computable answer) by reversing the question: how about each and every of the lot celebrating on different days? That's very easy to answer by the definition of 'chance': # wanted situations / # possible situations. # wanted situations = 365x364x363...x340 (365!/(365-26)!) # possible situations = 365x365x365...x365 (365**26) (of course you'll have to change 365 by 366 for a leap year, but that doesn't make much difference) With for example Free42 (a real HP-42S is slightly too "limited") you can easily calculate the quotient directly, but otherwise you'll have to program (almost any HP calc will do). Chance=1 ; FOR i=0 TO 25 ; Chance=Chance*(365-i)/365 ; NEXT which may translate for the HP-41C(V) into this: ```*LBL CHANCE 1 - 1000 / STO 00 1 STO 01 *LBL 01 365 RCL 00 INT - ST* 01 365 ST/ 01 ISG 00 GTO 01 RCL 01 ``` 26 XEQ CHANCE => 0.40(17591805) The answer 0.40 is the answer for the reversed question. So the answer to the original question is 1-0.40 => 0.60. So take 26 people at random, for example 26 readers of the HP museum forum and there's 60% chance that at least 2 of them were born on the same day in the year. And that's an unexpectedly high value, isn't it? With an increasing number of people the chance for 'all different dates' will approach zero and hence the chance for 'a duplicate' will approach certainty. With 366 or more people a duplicate will have become certain. Strangely enough, when I would ask (the other way round) for the chance for the existence of a date on which nobody has his/her birthday then this chance will never be equal to zero, no matter how many people I put together. Hard to believe that even for the entire Dutch population (about 16 million persons) there's a chance, albeit extremely low, that on one (or more!) date(s) nobody celebrates his/her birthday. It will never happen, but there is a chance ...

 Possibly Related Threads... Thread Author Replies Views Last Post Computing pi with the PC-1300S Kiyoshi Akima 0 771 11-17-2013, 12:24 AM Last Post: Kiyoshi Akima O.T. - but chances are you're gonna like it... Luiz C. Vieira (Brazil) 0 596 12-01-2012, 08:48 PM Last Post: Luiz C. Vieira (Brazil) Books on computing Elementary Functions Nick_S 4 1,194 09-14-2012, 07:33 AM Last Post: David Hayden (updated)somehow O.T. but chances are some of you might like it... Luiz C. Vieira (Brazil) 2 991 07-16-2012, 07:40 AM Last Post: Luiz C. Vieira (Brazil) Computing Square Roots Thomas Klemm 11 2,193 03-30-2009, 03:26 PM Last Post: Thomas Klemm 71B - Your chances of winning the lottery RonHudson(USA) 4 1,053 09-25-2007, 11:53 AM Last Post: Namir Computing many digits of Pi Juan Pablo Martinez (Spain) 21 3,670 09-24-2007, 10:58 AM Last Post: Egan Ford Chances of a bug-fixed 35s? Bruce Bergman 2 885 08-09-2007, 03:09 AM Last Post: Raymond Del Tondo Computing PI -- a simple programming problem Katie Wasserman 41 6,448 10-20-2006, 10:34 PM Last Post: Palmer O. Hanson, Jr. The risks of retro computing Bruce Horrocks 26 4,119 08-03-2006, 02:24 PM Last Post: Bill (Smithville, NJ)

Forum Jump: