Birthday Problem

Discussion in 'C++' started by Sandra, Apr 12, 2004.

  1. Sandra

    Erik Guest

    Please DO NOT post what you think is a complete answer to someone
    Who cares?
    If she gets a chance to get extra credit, she's probably supposed to
    solve it by herself, so she deserves a stupid answer.
    Perhaps not, or it could be your brain. You cut out most of my mail
    that explained why I wrote what I did. Didn't you understand that?
    Too stupid ones, if you ask me. (BTW, was I supposed to be
    impressed with you because you managed to find my location in the
    headers). Do you often try to find out as much personal information
    as possible about the people you disagree with? Shall I expect a dead
    pigeon's head in my mailbox soon?
     
    Erik, Apr 12, 2004
    #21
    1. Advertisements

  2. Sandra

    David Harmon Guest

    On Mon, 12 Apr 2004 17:13:27 +0000 (UTC) in comp.lang.c++, Christopher
    I am sure it cannot be correct to give Feb 29 the same weight as all the
    other days. Which is the closer approximation, to do as above or to
    ignore Feb 29 and calculate using 365?
     
    David Harmon, Apr 12, 2004
    #22
    1. Advertisements

  3. Thank you. Have you considered that perhaps Sandra cares? I think
    not, since not spotting something so basic indicates a dead brain.

    Thank you.

    Thank you. On my screen your message displays with this prominently in
    place at the top: "Lund Institute of Technology, Sweden". But perhaps
    for you that's as difficult to spot as "Sandra"?

    Thank you, again.

    Urgh, my thank-you box is near empty, so. In the future, please DO NOT
    post what you think is a complete solution to someone else's homework.
    ESPECIALLY when the originally poster asks you not to do so.
     
    Alf P. Steinbach, Apr 12, 2004
    #23
  4. Sandra

    Buster Guest

    Let p (n) be the probability that two or more people in a room have the
    same birthday when n people are in the room.

    "The first person will not match anyone."
    Therefore the probability that all the birthdays are different is 1.
    Therefore p (0) = 0;

    "The next person will have a different birthday with probability
    364/365."
    Therefore the probability that all the birthdays are different is
    1 * (364/365).
    Therefore p (1) = 1 - (1 * (364/365)) = (1/365) < 95%.

    "The next 363/365.".
    Therefore, the probability that all the birthdays are different is
    1 * (364/365) * (363*365).
    Therefore, p (2) = 1 - (1 * (364/365) * (363 / 365)) < 95%.

    In general, if there are n people in a room, the probability that
    all the birthdays are different is /* */.
    Therefore, p (n) = 1 - /* */.

    This is the solution I was taught as an undergraduate.
     
    Buster, Apr 12, 2004
    #24
  5. As a check to anything you code, I believe the number of people you
    have to have such that any two of them have the same birthday is a 50%
    probability is 20. This is a little different than exactly matching a
    specified birthday, but it may give you some insight into how the
    probability is calculated. This truly seems more like a math problem
    to me. The kind of bonus work I give is: "Given three int's entered by
    a user, determine the kind of triangle with those three sides in
    length would be; equilateral, isosceles, or scalene. Can you tell if
    the triangle is a right triangle?" This is for nested if's or switch's
    structures. At least the math isn't hard.
     
    Gary Labowitz, Apr 12, 2004
    #25
  6. Sandra

    John Carson Guest

    Like I said, the right answer to the wrong question. Here is the question
    from the OP:

    "Ok - The problem is to find out how many people need to be in a room
    for a 95% chance that someone in that room will match my birthday"

    Whether other people in the room besides "me" have matching birthdays is
    irrelevant.
     
    John Carson, Apr 12, 2004
    #26


  7. I think that the problem more simple than that.

    You need to know how many N people there must be so that
    the probability that *no* one has your birthday is just less that 5%.
    The probability that another person chosen at random doesn't have
    your same birthday is P = 364/365 (or, more accurately, 1457/1461).
    Choose N so that

    P^N < 5% = 5/100 < P^(N-1)

    or

    N-1 < log(5/100)/log(P) < N
     
    E. Robert Tisdale, Apr 12, 2004
    #27
  8. Hm, interesting point. Perhaps the real probabilities are

    A day that is not February 29: 4/1461
    February 29: 1/1461

    I despised probability and statistics in school, so the probability of
    the above being correct is probably not 1 ;) In any case, it should
    give the OP food for thought...

    P.S. Given the convoluted leap year rules, I'm actually quite certain
    that the above is not correct; it's probably closer to the truth than
    what I originally assumed, however.
     
    Christopher Benson-Manica, Apr 12, 2004
    #28
  9. Notice that in a followup to my post to which you followed up, I
    admitted that I had horribly botched the "solution" and amended it. I
    got 47, which may or may not be correct.
     
    Christopher Benson-Manica, Apr 12, 2004
    #29
  10. What about leap year?
     
    Christopher Benson-Manica, Apr 12, 2004
    #30
  11. Sandra

    osmium Guest

    Paris in the
    the spring.

    Damn!
     
    osmium, Apr 12, 2004
    #31
  12. Sandra

    Erik Guest

    If Sandra is very angry with me about that, I will give her all my
    apologies.
    Well, on mine it doesn't, I have to click a button to see the header.
    Now I see ABSOLUTELY no reason for you to ask those questions.
    Didn't you care to read my last post, or didn't you understand it?
    I didn't post what I think is a complete solution.

    I can't believe you can write, but you can't read.
     
    Erik, Apr 12, 2004
    #32
  13. Sandra

    Anonymous Guest

    If I understand the problem, this is _absolutely_ the _wrong_ group to
    post this question! This has nothing to do with programming, much less C++.
    The best thing you can say about this problem is that you'll have to
    implement the factorial function, or a variant, thereof.
    A more appropriate place to post this would have been sci.math. I might
    have even suggested alt.sci.math.probability, if it weren't for all the spam
    that happens there (undoubtedly as a result of it being an alt.*
    newsgroup...).
     
    Anonymous, Apr 12, 2004
    #33
  14. Just for completeness, since I've responded to the others in this thread
    doing the "Hey look I can solve novice homework problems!" as you now do:

    Please DO NOT post what you think is a complete answer to someone
    else's homework problem.

    However, I think this advice (which is also in the FAQ, as well as in
    Sandra's posting that you replied to) is wasted on you. It would be
    nice if you proved me wrong. But I do not expect that from you.
     
    Alf P. Steinbach, Apr 12, 2004
    #34
  15. Something that calls itself Anonymous wrote:

    [snip]

    This is an obvious troll. Please ignore it.
     
    E. Robert Tisdale, Apr 12, 2004
    #35
  16. Alf P. Steinbach wrote:

    [snip]

    Go away troll.
     
    E. Robert Tisdale, Apr 12, 2004
    #36
  17. Sandra

    Sandra Guest

    Gee thanks guys !

    Erik -

    #1 I am a Girl
    #2 I did not deserve a STUPID answer

    Alf -

    Thank You for sticking up for me while I was away
    I was brainblocked and just needed to know if I was
    on the right track. The exact problem as given to me
    states as below - yes this is a c++ class, the extra credit
    problems are always fun ones ..

    Extra Credit Problem ***

    Write a C Program that will determine how many people must be in a
    room in order to insure a 95% chance there is somebody in that room
    with your birthday.


    ~~ I sold my damn statitics book 5 years ago (wish I hadn't now)

    Robert -

    Thank you - I think I understand now !

    All - Looks like I caused an unintentional stir, I did not need code I
    just needed some brain stimulation

    Apologies,

    Sandra
     
    Sandra, Apr 12, 2004
    #37
  18. Sandra

    Buster Guest

    You're right.
     
    Buster, Apr 12, 2004
    #38
  19. Please don't top-post.

    * (Sandra) schriebt:
    Well, it seems your work is cut out for you, unless the context of the
    problem formulation is such that it really means something more than stated.

    All your program has to do is to ask you whether your birthday is February
    29th, and then apply the formula inconsiderately given you by Robert
    E. Tisdale and at least one more poster. The program could output one
    result based on the current year or on assuming a non leap-year, or it could
    output two result, one for non-leap and one for leap-year. In the latter case
    the formula should be suitably modified for leap year. Of course it could
    also output four results, one for each combination of February 29th or not and
    leap year or not. That way you could avoid the input part.

    Also, it might be possible to avoid the leap year thing by analyzing whether
    it can affect the result or not.
     
    Alf P. Steinbach, Apr 13, 2004
    #39
  20. Please don't top-post.

    * (Sandra) schriebt:
    Well, it seems your work is cut out for you, unless the context of the
    problem formulation is such that it really means something more than stated.

    All your program has to do is to ask you whether your birthday is February
    29th, and then apply the formula inconsiderately given you by Robert
    E. Tisdale and at least one more poster. In the case of February 29th the
    formula should be suitably modified. But it might be possible to avoid all
    that by analyzing whether it can affect the result or not.

    Also, it is possible to avoid the input part by having the program
    output two results, one for February 29th and one for any other birthday.



    [Note: an earlier version of this message, with extremely faulty logic (late
    night hurry), was posted and immediately cancelled, but might still have made
    it to your newsserver -- if so just ignore it.]
     
    Alf P. Steinbach, Apr 13, 2004
    #40
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.