Thursday, July 08, 2010

Tuesday Child Puzzle

There has been a lot of chatter about the Tuesday Child puzzle:
I have two children. One is a boy born on a Tuesday. What is the probability I have two boys?
Everyone's instinct is to say: Tuesday has nothing to do with it, so the answer is simply 1/2.

That answer is wrong. Here is the trouble with everyone's intuition: they read the problem as: I have one son born on a Tuesday, what is the probability that my next child will be a son? There the answer is 1/2. But that is not the problem at hand--here both children are already born. It's a different problem

The answer is actually 13/27 = 0.481, not 1/2.

Let's accept that for now. If you Google you'll find a lot of proofs, some with tables and some using complicated Bayesian analysis. I'll get the result later, via simulation, but for now we'll assume it is correct. But the way to think about it is this: there are lots of ways that two children can be born on any of seven days, say Boy on Tuesday and Girl on Saturday, all with equal probability, and exactly 1/4 of them have two boys. But as I place constraints, such as Boy on Tuesday, many of the possibilities are eliminated and the probabilities change. For example, I can place a very tight constraint: I have two children, one is a son born Tuesday and the other is a son born Saturday. What is the probability I have two sons? Why it is one of course, because all arrangements except Boy on Tuesday and Boy on Saturday have been eliminated by the constraints.

Of course Tuesday really has nothing to do with it. What is relevant is that a boy is constrained to be born on one specific day—any day would do--this could just as easily be the Friday Child Puzzle. It is the limitation that one of the children is a boy born on one specific day out of seven that is relevant.

To see this, assume you asked:
I have two children. One is a boy born on a Monday, Tuesday, Wednesday, Thursday, Friday, Saturday or Sunday. What is the probability I have two boys?
Clearly this is the same as simply asking: I have two children, one is a boy, what is the probability that the other is a boy? Here the answer is clear—the possible arrangements given that we have at least one boy are: BB, BG, GB. They occur with equal probability, so the probability of BB (two boys) is 1/3.

We could generalize the puzzle this way:

I have two children. One is a boy born no later than day N where N is 1..7. What is the probability I have two boys?

Let's call that probability P(N).

So the original form of the puzzle is: what is P(1)? The answer we are accepting (for now) is not 1/2 but 13/27.

The second form of the puzzle, where the constraint is a boy born on any of the seven days, could be stated this way: what is P(7)? That we just demonstrated is 1/3.

What is the meaning of P(0)? This would mean that the first boy wasn't born on any day. This pathological case becomes, simply, what is the probability that the other child is a boy, which is our beloved 1/2.

Let's make a prediction. We have:

P(0) = 1/2 = 14/28
P(1) = 13/27
P(2) = 12/26
P(3) = 11/25
P(4) = 10/24
P(5) = 9/23
P(6) = 8/22

P(7) = 7/21 = 1/3


P(2) through P(6) is a prediction from an obvious pattern. Let us remember what this means. P(1) is the probability of two boys given that one son is born on one specific day, say Tuesday. P(2) is the probability given that one son is born on one of two days, say Tuesday or Wednesday. Etc., etc., etc.

I wrote a Monte Carlo for this problem and the results are:

Days   Prob of 2 boys
-------------------
 P(1)       0.4811
 
P(2)       0.4615
 
P(3)       0.4399
 
P(4)       0.4167
 
P(5)       0.3911
 
P(6)       0.3631
 
P(7)       0.3336


These are good approximations to the predicted fractions above. The zero row is not in the output because it is a pathological case and the code won't handle it.

Note that P(1), as advertised, is 13/27.

The probability (that the second child is a boy) drops smoothly from P(0) = 1/2 (when in effect there is no first child) to 1/3 when the first child is a boy, born any day.

The JAVA program is given below.

public class TuesdayChild {

//constant defining a boy baby
   private static final int BOY = 0;

//method that randomly selects a sex
   private static int randomSex() {
     return (int)(Integer.MAX_VALUE*Math.random()) % 2;
   }

//method that randomly selects a day, 0--6 
  private static int randomDay() {
    return (int)(Integer.MAX_VALUE*Math.random()) % 7;

  }

//main method
   public static void main(String arg[]) {
     TuesdayChild tchild = new TuesdayChild();

//how many trials per iteration
     int numTrial = 10000000;

//hold the results for each case. We will vary the
//number of days one boy is constrained to be born on
//from 1 (corresponding to the problem as stated) to 7

     double results[] = new double[7];

//loop over the constraint days 

    for (int numDays = 1; numDays <= 7; numDays++) { 
      int passCount = 0; //number of trials passing constraint
      int twoBoyCount = 0; //subset that have two boys

//now loop over the trials
     for (int i = 0; i < numTrial; i++) { 

      Trial trial = tchild.new Trial(numDays); 
      if (trial.keepTrial()) { 
        passCount++; 
        if (trial.twoBoys()) {
          twoBoyCount++; 
        } 
      } 
    } 
    results[numDays-1] = ((double)twoBoyCount)/passCount; 
  } 
//now print the results
   System.out.println("Days Prob 2 boys"); 
   System.out.println("-------------------");
   for (int numDays = 1; numDays <= 7; numDays++) {

      System.out.println(String.format("%d %8.4f", numDays, results[numDays-1])); 
    } 
  } 

//class for a single trial
   class Trial {
//sex of child 1 and child 2
   int sex1 = randomSex();
   int sex2 = randomSex();

//day of birth child 1 and child 2
   int day1 = randomDay();
   int day2 = randomDay();

//this will determine how many days we constrain the birth
//of one boy. It can be 1--7. At one, one boy will be constrained
//to be born on one day, such as Tuesday. This is analogous to the
//puzzle as stated. If it is two then one boy is constrained to be
//born on two days, say Tuesday or Wednesday. If it is seven, one boy
//is constrained to be born on any day. This is the same as simply saying
//you have one boy. The answer for that case should be 1/3.

   int _max;

   public Trial(int max) {
     _max = max;
  }

//see if we keep this trial because at least one of the two children
//was a boy born within the constrained number of days

   public boolean keepTrial() {
     return ((sex1==BOY)&&(day1<;_max)) || (sex2==BOY)&&((day2< _max)); } 


//see if this trial has two boys
   public boolean twoBoys() {
     return (sex1 == BOY) && (sex2 == BOY);
     }
   }
}

12 comments:

  1. Larder9:07 PM

    Wow, this is pretty neat. Even when you see it laid out, it still isn't intuitive. I had a statics professor bring up the "Let's make a deal" problem a few semester ago. I still can't convince anyone that swapping doors is the best choice.

    ReplyDelete
  2. Anonymous8:35 PM

    This comment has been removed by a blog administrator.

    ReplyDelete
  3. Hm. I'm not convinced: the boy has to be born on some day, so that day can be reported.

    The problem is really semantics, not maths. The question can be read as saying "I have two children. One is a boy. What is the probability I have two boys? BTW, the boy referred to was born on Tuesday". That would imply that Tuesday is irrelevant. The question is poorly worded, has 3 or 4 'correct' answers, depending on how it is interpreted.

    FWIW, I think 2/3 is the right answer.

    ReplyDelete
  4. Bob O'H said it: unless saying "One is a boy born on a Tuesday" eliminates the possibility that there is a second boy, also born on a Tuesday, which it doesn't seem to logically, then the answer would remain 2/3.

    ReplyDelete
  5. Anonymous9:17 AM

    This comment has been removed by a blog administrator.

    ReplyDelete
  6. I'm just figuring this out myself... but the apparently paradoxical answer does not require that it eliminates the possibility that there is a second boy born on Tuesday.

    The point is that if the other child is not a boy born on Tuesday, then it could have been either the first or the second child. So the probability of those outcomes is effectively "doubled" (I'm speaking loosely here). But if the other child is a son born on Tuesday, then we know for a fact that the first child had to be a son born on Tuesday -- which means we don't get to do the double-counting I alluded to earlier.

    It really bothers me, but I think this is correct.

    ReplyDelete
  7. Okay, Bob O'H, I've got a rebuttal.

    I am going to randomly pick letters out of a hat, where the possibilities are "A", "a", "B", and "b". All are equally probably. One of the letters is a lower-case "a". What is the probability that the other letter is an "A/a", i.e. either case?

    P(aa) = 1/16
    P(Aa) = 1/16
    P(aA) = 1/16
    P(ba) = 1/16
    P(ab) = 1/16
    P(Ba) = 1/16
    P(aB) = 1/16
    ------------
    Total = 7/16

    P(aa)+P(Aa)+P(aA) = 3/16

    So the answer to the question is 3/7. With me so far?

    Now, would your answer change if I phrase the question like this:

    I am going to randomly pick letters out of a hat, where the possibilities are "A", "a", "B", and "b". All are equally probably. One of the letters is some type of A. What is the probability that the other letter is an "A/a", i.e. either case? Oh by the way, the first letter I mentioned is lower-case.

    ReplyDelete
  8. My restaurant has 14 items on the menu: Burger, burger w/cheese, chicken, chicken w/cheese, fish, fish w/cheese, pulled pork, pulled pork w/cheese, tofu, tofu w/cheese, alligator, alligator w/cheese, goat, and goat w/cheese.

    Three questions:

    I have an order in for two items. One of the items has cheese. What are the odds the other item has cheese? Answer = 1/3

    I have an order in for two items. One of the items is a burger w/ cheese. What are the odds the other item has cheese? Answer = 13/27

    I have an order in for two items. One of the items has cheese. What are the odds the other item has cheese? Oh by the way, the aforementioned item is a burger. Answer = STILL 13/27.

    Right?

    ReplyDelete
  9. timwit11:58 PM

    This is an intriguing puzzle, prompting me to offer an excel-based precise solution along with delivery tips at this site

    ReplyDelete
  10. Anonymous8:01 AM

    Unfortunately, these questions you ask are ambiguous, and it is the failure to recognize how they are ambiguous that causes the results to seem unexpected. Consider two versions of what led up to the first statement:

    Case #1: A father is chosen at random. He is given a slip of paper as he is led onto a stage. The paper says "Pick one of your children. Tell the audience the number of children you have, the chosen child's gender, and the day of the week on which it was born."

    Case #2: A father is chosen at random from all fathers who have two children, including one boy born on a Tuesday. He is also ushered onto a stage and given a slip of paper that instructs him to tell the audience the criteria used to select him.

    Now shift scenes. You are in the audience when a man is ushered onto the stage. He looks at a slip of paper, thinks a moment, and says "I have two children and one of them is a boy born on Tuesday." What is the probability that he has two boys?

    The answer to the question depends on which case applies to the man you listened to. In Case #1, it is 1/2. In case #2, it is 13/27. Your simulation only covered the second case. To get the first, after you have two children, flip a coin to see which one the father will tell about. If it is not a Tuesday Boy, don’t keep that trial even if the other child is a Tuesday Boy. You will find that the 27 cases where you have a Tuesday Boy reduce to 14 (just over half, since one father didn’t need to flip the coin), the 13 where you also have two boys reduces to 7, and the answer is exactly 1/2.

    If you simulate the simpler problem, where you don’t worry about the day of the week, the answers are 1/2 and 1/3 for the two cases, respectively. The reason 13/27 seems unintuitive, is because the fact that a Tuesday Boy was REQUIRED in the second case is not intuitively obvious from the statement "one of them is a boy born on Tuesday." In fact, as you point out, the puzzle could equally well be named after either of your two children, which is probably two different names. You choose one, just like the father in case #1, so the better answer to your question is 1/2, not 13/27. It is still ambiguous, but there is no valid reason to assume that case #2 applies.

    ReplyDelete
  11. Anonymous9:05 PM

    Nice explanation at 8:01AM. The ambiguity of translating English to mathematics leads to many of these probability "paradoxes." Even when the original story seems straightforward, as is this case, the conditional probabilities, which depend on unstated assumptions, are not always precisely defined by the story. E.g. cases #1 and #2.

    ReplyDelete
  12. The Deuce4:21 PM

    I remember John Derbyshire demonstrating this same problem on the Corner not long ago. Although I didn't bother to work it out, I *did* figure out why the answer wasn't intuitive (namely, that people confuse the question with "What are the chances that my next child will be a boy?"). Weirdly, he didn't seem to, or at least he didn't let on that he had, even though he showed the right answer.

    ReplyDelete