Settings

Theme

Online executable Python solution to the Tuesday boy problem

ideone.com

2 points by daivd 12 years ago · 10 comments

Reader

x0054 12 years ago

This answer is incorrect. There is a 1/4 chance that both children are boys, and each child has 1/2 chance of being borne a boy, regardless of what day his sibling was or will be borne on. The program arrives at the probability of 13/27 by excluding the possibility that both children might be borne on tuesday and both might be boys.

  • daivdOP 12 years ago

    No, it does not exclude that possibility (print the final list of pairs if you want to check). The calculation is correct. The result is counter-intuitive to almost everyone, which is why I made the program, so you can convince yourself.

    • x0054 12 years ago

      Nope, sorry, it's wrong. Here are the possibilities for someone with 2 children were at least one of them is a boy borne on tuesday:

        01) 1BT 2BM
        02) 1BT 2BT
        03) 1BT 2BW
        04) 1BT 2BR
        05) 1BT 2BF
        06) 1BT 2BS
        07) 1BT 2BY
        
        08) 1BT 2GM
        09) 1BT 2GT
        10) 1BT 2GW
        11) 1BT 2GR
        12) 1BT 2GF
        13) 1BT 2GS
        14) 1BT 2GY
        
        15) 1BM 2BT
        16) 1BT 2BT
        17) 1BW 2BT
        18) 1BR 2BT
        19) 1BF 2BT
        20) 1BS 2BT
        21) 1BY 2BT 
        
        22) 1GM 2BT
        23) 1GT 2BT
        24) 1GW 2BT
        25) 1GR 2BT
        26) 1GF 2BT
        27) 1GS 2BT
        28) 1GY 2BT
      
      Your program counts possibility # 2 and 16 only once, because at first glance they are identical. But they are not, because each child has independent probability. This is why models that graph this information on a grid also fail to get the right answer. The above probability table gives you the proper result of 14/28, or 1/2.
      • daivdOP 12 years ago

        Actually you are still wrong.

        Try something easier, for example two dice. The probability to roll 1 1 is less than to roll 1 2, because 1 2 can be rolled either by first rolling a 1 or a 2, while 1 1 can be rolled only by first rolling a 1. That information is used often in dice games like backgammon.

        Same with children: BT BT can only be "rolled" if your first child is BT, whil BT BW can be "rolled" if your first child is either BT or BW.

        Do you see?

        • x0054 12 years ago

          The probability that you will roll 1 1 is indeed less then rolling 1 2 or 2 1, but that's only because you are allowing for twice as many acceptable outcomes.

          The Wiki article you reference in your own code explains it well. The problem is in the assumptions made by the person answering a riddle. Just because you have a child, and it's a boy, and he is born on Tuesday, it does not mean that your next child is more likely to be a girl. If you agree with that statement, then the original answer must be false.

          • daivdOP 12 years ago

            The wiki article is not valid, since it considers a subtly different problem than the one I do. If you read the comment at the top of the code, you will see that I changed the question to be less ambiguous.

            In the problem I pose, the person does not randomly come forward and tell me "I have a boy born on a tuesday". In my problem I ask random people who I know have two children if they have "at least on boy born on a tuesday" until someone says yes.

            • x0054 12 years ago

              My python is really rusty, but if you convert this sudocode to python, you will see that the answer is 50/50. I'll write this up in Javascript when I have time. If you do this in Python, please post.

                 girl = 0
                 boy  = 0
              
                 do 10000 times {
                    child1Sex = randomSex;
                    child1Day = randomDay;
                    child2Sex = randomSex;
                    child2Day = randomDay;
                    if ( (child1Sex == "B" AND child1Day == "Tu") OR (child2Sex == "B" AND child2Day == "Tu") ) {
                       if (child1Sex == child2Sex){
                          boy++
                       } else {
                          girl++
                       }
                    }
                 }
              
                 print "Ratio of boys and girls is " + boy " : " + girl;
              • daivdOP 12 years ago

                I whipped together something here, before I saw that someone else did it too: http://ideone.com/jyPOhs

                It is the most counter-intuitive statistic problem I know (worse than Monty Hall), it trips everyone up at first.

                No problem about the stubborness ;)

              • krapp 12 years ago

                Here's my attempt in python: http://pastebin.com/tSDK1uRv

                the range(0,10000) may not be correct, it might need to be 1,10000

                • x0054 12 years ago

                  Wow, works good. I should learn python :) But yeah, you were absolutely right! It was hard for me to figure out because I was trying to find a mathematical reason for this, and I was wrong. I finally figured it out mathematically. The way you posit the problem the probability that the asked parents have another boy is (1/2)-(1/7/2).

                  This is really counter intuitive, the open vs. closed probability set through me off. Hey, thanks for putting up with my stubbornness!

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection