Tuesday, December 28, 2010

On babies, batting averages, and weighted means

Here's a famous old math problem you've probably seen many times before:

A king decides that his country has too many men and not enough women. So he issues a decree: once a couple has a boy, they're not allowed to have any more babies.

The king reasons as follows: no family will have more than one boy. But some families will have two girls, or three girls, or even six girls before they have a boy. So there will wind up being a lot more girls than boys.

Is the king's reasoning correct?

The answer: the king's reasoning is not correct. There will still be 50 percent boys, and 50 percent girls. There are many ways to figure this out. I'd refer you to a solution on the internet, but I can't seem to find the problem. (Can anyone supply a link?)

There's a certain country where everybody wants to have a son. Therefore each couple keeps having children until they have a boy; then they stop. What [is the expected value of the] fraction of the population [that] is female?

At first, this seems like the same question. But it's not. As Landsburg explains, the answer to this one is *not* 50 percent.

But even though the answer isn't 50 percent, it *seems* like it should be -- so much so that commenters are perplexed. One reader, a physics professor, seems certain that Landsburg is wrong, and that the answer is indeed 50 percent. Landsburg has challenged him to a $15,000 bet.

Landburg is indeed correct. I'm going to try explaining why, with a baseball analogy. But before I do, think about it a bit, and maybe read Landsburg's posts, to try to figure it out for yourself. It took me a while to get my head around it.

-----

OK, here we go.

Suppose that in a given season, the overall MLB batting average is .250. What is the average player's batting average?

The answer is NOT .250. But this time it's a lot easier to figure out why.

If you check, you will find that the average major leaguer hits less than the league average .250.

Why? Because when you average individual players, you give them equal weight. But when you figure out the composite MLB average, you weight by the number of at-bats. And good players have more AB than bad players. Therefore, the overall average is inflated by the fact that you weight the good players more heavily, and will wind up being higher than the average of the individual players weighted equally.

This is easier to see with an example. Suppose there are two players in the league. Player A goes 100 for 399, for a batting average of .251. Player B, who is a pitcher, goes 0 for 1. The average player went .125 (the average of .251 and .000). But, overall, the league hit .250 (100 for 400).

Weighted by AB, the league hit .250. Weighted by player, the league hit .125.

Got it for baseball? Now, let's apply it to Landsburg's problem. Because births are random, and we want the average, imagine repeating the birth simulation for a million different countries.

In baseball, players with more AB have a higher proportion of hits. In Landsburg's example, countries with more births have a higher proportion of girls. That's obvious, isn't it? If there are 100 families in the country, there'll always be 100 boys at the end. The only difference, then, must be the number of girls. Countries with more babies, then, *must* have more girls, and therefore a higher proportion of girls.

So we have exactly the same situation for countries as for batters.

-- Country A might have 100 boys and 91 girls, which means a .476 "girling average".-- Country B might have 100 boys and 109 girls, which means a .522 "girling average".

Overall, there are 200 boys, and 200 girls, for a composite average of .500. However, the average *country* has an average of only .499 (the average of .476 and .522).

If you weight the average by *babies*, you get .500, as expected. But if you weight it by *countries*, you get .499.

Landsburg's question requires you to weight the average by country, and that's why the answer is less than .500.

The highlighted text in Landsburg's initial post is completely ambiguous.

The paragraph right below it clarifying the post doesn't help much, if at all. Landsburg essentially requires you to assume some unspecified, but finite, initial number of couples in the country. He mentions this in the third post where he lays down the terms of the bet (4 initial couples), but not in the first two.

In a brainteaser, it's entirely fair to assume an infinite population.

Professor Motl does indeed realize the difference between "weighted by children" and "weighted by families." But he fails to realize that "weighted by countries" (which is what Landsburg is asking) requires the same kind of logic, and will be lower than 50% for the same reason that "weighted by families" is lower than 50%.

"Population" doesn't seem clearly defined. If you assume population to be equal to the sum(families) then: the expected value is E[girls/population], or sum( p(girls/population)*girls/population, girls=0..population). If for example population is FINITE then this is correct, if population is INFINITE, then the answer would be 50%. Or, the limit as population goes to infinity: SUM(p(girls/population)*girls/population, girls=0..population) = 50%.

That said this problem should approach 50% very quickly for large populations (>1000?).

If the problem asked what is the expected percentage of females in a single family then it would be more obvious, however the term population suggests more than one family.

Check out this spread sheet (google docs / large). It has 100 "populations" each population has 100 families. Clearly the families female percentage is close to 30%, but the population for a group of families averages to 50%.

Right, the answer approaches 50% as the population approaches infinity.

I suspect that for any reasonable number of families, the answer is so close to 50% that a simulation won't be able to distinguish. But it's still not 50%. :)

The whole point of Landsburg's post was that the answer is not 50%, and the traditional logic is wrong.

If anyone out there read the question and said, "it's less than 50% for small numbers of families, but approaches 50% as the number of families gets large," you have my congratulations. My first reaction was, "of course it's 50%." And it took me a fair bit of effort to figure out why that logic was wrong.

As I said on the Book blog, it has nothing to do with the number of families. The question, regardless of the number of countries (or the number of families) depends on if there is a limit to the number of girls a family can have. If there is (which there will be in reality), it is exactly 50/50. If there isn't, then there is no answer, as in an infinite sample size, there will be at least one family with an infinite number of girls, and in order to figure the percentage of girls or boys, you would have to divide by infinity.

If you assume that every family has a boy, then the answer is that boys have a slightly higher percentage than girls (becasue we have a population that was slectively sampled - no families with all girls).

Landsburg is all wet. His explanations are horrendously unclear (and wrong).

Hmmm... after reading more comments on that guys blog, my comment above isn't as appropriate I don't think. It's a simple explanation, and I think it's factually correct, but it doesn't get at the weighting that Phil does in his actual post here.

MGL makes a great analogy in the comment above my first one, too, which of course relates to gambling!

I looked at Landsburg's original post, read a bunch of the comments, and then read Landsburg's followup post along with comments, plus the web sites of two or three of his most voracious critics.

My take: he is correct for his version of the problem, but he changed it from the original problem that he got from Google. The Google question asks "what fraction of the population is female?".

Given that the Google version specifies a country, it is reasonable to assume a population of thousands. It would also be reasonable to assume that women have a limited childbearing period, thus leaving some families with all girls. Using those assumptions, the answer is so close to 50% to be indistinguishable from it.

Landsburg changed the parameters, but then he claims that Google's answer of 50% is wrong. The thing is, he's solving a different problem that the one posed by Google. I find that somewhat dishonest.

The question, "What fraction of the population is female?" has to be interpreted. Otherwise, "it could be almost anything!" is the correct answer, since the result will be random.

I think the most plausible interpretation is, "What is the expected value of the fraction of the population that is female?" That's Landsburg's question. And that answer is not 50%.

In an idealized brain teaser of this sort, it's usually reasonable to make unrealistic assumptions to keep the problem simple. I suppose you could assume a limited childbearing period, but that still wouldn't give you an answer of 50%, unless the childbearing period was one child.

The obvious answer is, "it's 50% because the selection process can't possibly produce more girls than boys." That's wrong. The correct answer is, "it's very close to 50% but still less than 50%, for counterintuitive reasons that are explained in Landsburg's blog [and here]."

In any case, I agree that anyone who interpreted the problem differently and solved THAT problem correctly with the correct explanation deserves full credit. My perception is that none of the critics have done that, and that many of the ones who say you have to interpret the problem differently *even got the wrong answer for their interpretation*.

For instance, if you assume a limited childbearing period, what's the answer? I think it's somewhere between the answer to the Landsburg problem, and 50%. But I can't prove that, and I haven't seen it solved by anyone.