Boy or Girl?

Mr. Smith has two children. At least one of them is a boy. What is the probability that both children are boys?

When I was a boy, I spent a lot of time in public libraries. It was the easiest way to find information for free back then. I was obsessed with computers (I haven’t changed), so every visit usually began by casing the 000 shelf, the Dewey decimal classification for books on programming.

Then I’d scamper to 794, which sometimes had a few books on programming computer games. Too few, all too often, so as a consolation prize, I’d check out intriguing titles in the vicinity. Board games. Magic tricks. And recreational mathematics, where I discovered Martin Gardner through books that collected his Mathematical Games columns from Scientific American.

One of them posed the above puzzle, and the answer supplied by Gardner shaped my initial views on probability, as it would be years before I encountered the subject in school. As usual for these problems, we assume each child has a 50% chance of being a boy (B) or a girl (G), thus for any two-child family, the probability of each of the four possible cases BB BG GB GG occuring are equal. We’re told GG is impossible, leaving three equally likely cases, so \(P(BB) = 1/3.\)

Decades later, I sneered at a work colleague for disputing this sacred figure. He claimed Mr. Smith could just have easily mentioned the other child instead, thus the unmentioned child has even odds of being a boy or girl. In particular \(P(BB) = 1/2.\)

This occurred well after the internet was everywhere, but I had been so sure of myself that I had never bothered searching for this puzzle. When I finally did poke around, I was stunned to learn that my colleague’s views were acceptable. The puzzle is widely regarded as ambiguous. Martin Gardner himself even says so; as a child, I had skipped over the follow-up discussion in a later chapter of his book.

The underlying issue became especially clear for me when I read about a variation on the original puzzle:

Mr. Smith has two children. At least one of them is a boy born on a Tuesday. What is the probability that both children are boys?

If we follow the same reasoning as above, the addition of "born on a Tuesday" changes the answer from 1/3 to 13/27. This sat poorly with me, as an additional incidental fact ought to have little or no impact on the solution.

No-nonsense solutions

Mathematics cuts through the confusion. Dijkstra:

The virtue of formal texts is that their manipulations, in order to be legitimate, need to satisfy only a few simple rules; they are, when you come to think of it, an amazingly effective tool for ruling out all sorts of nonsense that, when we use our native tongues, are almost impossible to avoid.

Compare with Wigner: "unreasonable effectiveness of mathematics in the natural sciences".

We’ll go full Jaynes. Let \(X\) be our background assumptions such that:

\[ P(BB|X) = P(BG|X) = P(GB|X) = P(GG|X) = \frac{1}{4} \]

Let \(D\) be the proposition that Mr. Smith has at least one boy. As a boolean expression:

\[D = BB + BG + GB\]

(Our notation is confusing because symbols like \(BG\) are not products of two other symbols, but rather are individual propositions. Sorry.) Trivially:

\[ P(D|BB,X) = 1 \]

and by the sum rule:

\[ P(D|X) = P(BB|X) + P(BG|X) + P(GB|X) = \frac{3}{4} \]

Bayes' theorem leads to Martin Gardner’s first answer:

\[ P(BB|D,X) = \frac{P(D|BB,X) P(BB|X)}{P(D|X)} = \frac{(1)(1/4)}{3/4} = \frac{1}{3} \]

Next, let \(D'\) be the proposition that Mr. Smith uniformly sampled one of his two children ("he could have just as easily mentioned the other child") and then revealed a male was chosen. We have:

\[ \begin{align} P(D'|BB,X) &= 1 \\ P(D'|BG,X) &= \frac{1}{2} \\ P(D'|GB,X) &= \frac{1}{2} \\ P(D'|GG,X) &= 0 \end{align} \]

By the sum rule and four applications of the product rule:

\[ \begin{align} P(D'|X) &= P(D’BB|X) + P(D’BG|X) + P(D’GB|X) + P(D’GG|X) \\ &= P(D'|BB,X)P(BB|X) + P(D'|BG,X)P(BG|X) \\ &+ P(D'|GB,X)P(GB|X) + P(D'|GG,X)P(GG|X) \\ &= \frac{1}{4}\left(1 + \frac{1}{2} + \frac{1}{2} + 0\right) \\ &= \frac{1}{2} \end{align} \]

Bayes' theorem yields:

\[ P(BB|D',X) = \frac{P(D'|BB,X) P(BB|X)}{P(D'|X)} = \frac{(1)(1/4)}{1/2} = \frac{1}{2} \]

and we have derived the competing answer that better matches intuition.

Sanity check

We simulate the above scenarios to confirm our theory matches practice. First, we simulate generating 150 families with two-children and discard those with no boys:

parseFrac = uncurry (/) . foldl (\(a, b) d
  -> (a*10 + fromIntegral (ord d - ord '0'), b*10)) (0.0, 1)
jsrandom = parseFrac . drop 2 <$> jsEval "Math.random()"

genFam = map ("BG"!!) <$> replicateM 2 (floor . (*2) <$> jsrandom)
do
  fams <- replicateM 150 genFam
  putStrLn $ "Generated 150 families: " ++ show fams
  let
    onePlusBoys = filter (elem 'B') fams
    oneCount = length $ onePlusBoys
    bothCount = length $ filter (== "BB") onePlusBoys
  putStrLn $ "Count of those with at least one boy: " ++ show oneCount
  putStrLn $ "Count of those with two boys: " ++ show bothCount
  putStrLn $ show bothCount ++ " / " ++ show oneCount ++ " = " ++ show (fromIntegral bothCount / fromIntegral oneCount :: Double)

The resulting ratio should be close to one third. (Click on the code and hit Ctrl+Enter or click the play button to rerun.)

Next, we generate 150 two-child families and have Mr. Smith randomly choose one of the two children. We discard the cases where he has chosen a girl:

do
  fams <- replicateM 150 genFam
  putStrLn $ "Generated 150 families: " ++ show fams
  picks <- zipWith (!!) fams <$> replicateM 150 (floor . (*2) <$> jsrandom)
  putStrLn $ "For each family, Mr. Smith picks a child at random: " ++ show picks
  let
    onePlusBoys = map snd $ filter ((=='B') . fst) $ zip picks fams
    oneCount = length $ onePlusBoys
    bothCount = length $ filter (== "BB") onePlusBoys
  putStrLn $ "Count of times Mr. Smith picks a boy: " ++ show oneCount
  putStrLn $ "Count of those families with two boys: " ++ show bothCount
  putStrLn $ show bothCount ++ " / " ++ show oneCount ++ " = " ++ show (fromIntegral bothCount / fromIntegral oneCount :: Double)

This time, the ratio should be close to one half.

Mind your language

Does the puzzle mean \(D\) or \(D'\)? Regrettably, we must now depart the precise utopian world of mathematics and wrestle in the mud of natural languages.

One could argue that "at least one of them is a boy" should directly translate to:

\[D = BB + BG + GB\]

After all, aren’t boys and girls obvious window dressing for heads and tails that make the puzzle more relatable? If we flip two coins and announce they are not both tails, wouldn’t any mathematician conclude the probability both are heads is 1/3?

However, one could also argue that we appeal to reality to justify \(X,\) so for consistency we ought to appeal to reality when considering how we learned that there is at least one boy; naming the father as "Mr. Smith" suggests we’re chatting with him.

Indeed, some retellings of this puzzle involve, say, a boy answering the door. But whether explicitly stated or not, we typically learn about the families of others through casual conversation or observation. For example, Mr. Smith may have thought of one of his children while chatting, and subsequently shared some information about that child, which suggests choosing \(D'\) over \(D.\)

Which is correct? Both, so long as the assumptions are stated. The puzzle maker should have been unambiguous if they wanted only one answer to be correct.

Let’s go again

Let’s say we accept the \(D'\) interpretation of the puzzle, so one of the following two propositions is true:

  • \(B_1:\) Mr. Smith has one boy and one girl.

  • \(B_2:\) Mr. Smith has two boys

and each is equally likely:

\[ P(B_1) = P(B_2) = 1/2 \]

From this starting point, Mr. Smith can again sample one child uniformly and reveal the gender. Suppose he does so, and he reveals it’s a boy. Let’s label this outcome \(D''.\) Then:

\[ P(D''|B_1) = 1/2 \]

\[ P(D''|B_2) = 1 \]

When comparing two hypotheses, we can use the shortcut:

\[ \frac{P(B_2|D'') }{ P(B_1|D'')} = \frac{P(D''|B_2)}{P(D''|B_1)} = 2\]

As \(B_1 , B_2\) are the only hypotheses, we have:

\[ P(B_2|D'') + P(B_1|D'') = 1 \]

implying \(P(B_2|D'') = 2/3 .\)

We could keep going; the more Mr. Smith samples one of his kids uniformly and reveals the gender as male, the more we believe both children are boys; after all, if \(B_1\) were true, the probability of picking the boy \(n\) times in a row is \(1/2^{n}.\)

The jump from \(P(B_2) = 1/2\) to \(P(B_2|D'') = 2/3\) is known as Bertrand’s box paradox, because it can seem counterintiutive when couched in certain terms. Further jumps are probably too obvious to disguise.

Chrystal unclear

In an 1891 paper, George Chrystal posed a similar problem:

A bag contains three balls, each of which is either white or black, all possible numbers of white being equally likely. Two at once are drawn at random and prove to be white; what is the chance that all the balls are white?

Since there are at least two white balls, one of the following two propositions is true:

  • \(W_2:\) The bag contains two white balls and a black ball.

  • \(W_3:\) The bag contains three white balls.

Let \(D\) be the proposition that two balls were drawn at random and both were white. Trivially:

\[ P(D|W_3) = 1 \]

By considering the ball not chosen, we quickly find:

\[ P(D|W_2) = 1/3 \]

Hence:

\[ \frac{P(W_2|D)}{P(W_3|D)} = \frac{P(D|W_2)}{P(D|W_3)} = \frac{1}{3} \]

so the odds are 3-to-1 in favour of \(W_3.\)

Chrystal computed this correctly, but he disliked the answer. He fell for Bertrand’s box paradox, and felt that both probabilities should be 1/2.

No one would say that if you simply put two white balls into a bag containing one of unknown colour, equally likely to be black or white, that this action raised the odds that the unknown ball is white from even to 3 to 1.

I wonder how Chrystal would have reacted if the sampling procedure were repeated, say, 20 times, and each time two white balls were drawn. Would he still have insisted there is only a 50% chance of \(W_3?\)

Or imagine two hypotheses, equally likely:

  • the bag contains 100 white balls

  • the bag contains 2 white balls and 98 black balls

Surely even Chrystal would believe that randomly drawing two white balls would strongly favour the first hypothesis?

At any rate, Chrystal found the calculation so offensive that he ruled that Bayes' theorem was unreliable and omitted it from his influential Algebra textbook.

The Miseducation of Ronald Fisher

Sandy L. Zabell, R. A. Fisher on the History of Inverse Probability, describes Ronald A. Fisher’s take on the history of probability in the late 19th century. Unsurprisingly, Fisher claimed to witness "increasing disaffectation with Bayesian methods".

In reality, Fisher himself was largely responsible for the suppression of Bayesian reasoning. If it weren’t for the untold harm caused by his frequentist takeover, the story would be a comedy of errors. Fisher builds his case by citing Boole, Venn, and Chrystal, but he mischaracterizes each of them, sometimes in a pleasing poetic fashion.

Fisher was unaware of Chrystal’s reasons for omitting inverse probabilities from Algebra. If only he knew that the two of them had complementary reasons for shunning Bayesian methods. Chyrstal was comfortable with ignorance priors; he simply thought Bayes' theorem could lead to the wrong answer! Fisher, on the other hand, accepted Bayes' theorem, but rejected ignorance priors.

Zabell states that had Fisher read Chrystal’s obscure 1891 paper, "Fisher would have found a serious embarrassment". Chrystal’s problem would have been trivial for him, and I imagine Fisher would have mercilessly mocked the puerile denial of an elementary identity.

Zen Bayesianism

The boy or girl paradox is a koan that ultimately led me to enlightenment, namely Bayesian reasoning.

Complex intractable disagreements are laid bare when the background assumptions are exposed. Disagreements may continue, but now their scope is restricted to the assumptions, because none can contest the sums and products of probabilities (except people like Chrystal). Closer scrutiny of controversial assumptions suggest the next steps; perhaps we ought to gather data to determine which assumption is more plausible.

David Mackay, Information Theory, page 26, sums up the realization that long eluded me:

you cannot do inference without making assumptions.

As Clayton notes, this requires effort: "the correct process of probabilistic inference involves a faithful accounting of background information and assumptions, which is conceptually tricky and enormously difficult."

Just as Chrystal rejected Bayes' theorem, Fisher rejected this principle. Not just because it’d be nice to "bypass the hard work of precisely describing our state of knowledge, enumerating all the background assumptions we bring to the table, etc.", but more fundamentally, because assumptions are subjective.

But assumptions are inescapable, because you cannot transform the unknown into the known, and Fisher’s unattainable desire for objectivity turned out to be a good intention that paved the road to frequentist hell. Clayton:

In their quest for objectivity, they established a school of statistical reasoning with no role for prior information, which they claimed was unnecessary for scientific inference. This was equivalent to saying premises are unnecessary for deductive reasoning, violating the rules of valid logic, but validity wasn’t their goal. It was not enough for their methods to be logically valid; Galton, Pearson, and Fisher needed their conclusions to appear to be objectively true. We do not yet know the full wages of that sin. But one consequence is that scientists are now largely saddled with frequentist statistical techniques that prove inadequate outside the narrow domains for which they were derived…​

I would love to trace frequentism’s missteps back to a renowned mathematician flubbing an amusing diversion that I encountered as a child, but that’s going too far. Even if Chrystal hadn’t fooled himself, or even if Fisher had read Chrystal’s 1891 paper, Fisher likely would still be hostile to inverse probability due to his ideology. And although his case would have been weaker without Chrystal, he might still get his way thanks to his brilliance and forceful personality.

Nonetheless, we can say that for embarrassing reasons, a little puzzle played an outsized role in the history of probability.


Ben Lynn blynn@cs.stanford.edu 💡