Last week I posted a little brain teaser that shows up frequently in recreational puzzle books — and reportedly in Google job interviews. The interesting thing about that puzzle is that the “official” answer is wrong. Not only that, but it’s wrong for an interesting reason.

I explained the official answer, I explained exactly where it goes wrong, and I explained how to get the right answer, citing Douglas Zare’s post here as inspiration.

The physicist Lubos Motl, however, still defends the official “50%” answer on his own blog. I am therefore offering to bet him $15,000 that I’m right (with detailed terms described below). If you agree with Lubos, this is your chance to get in on the action. I will take additional bets up to $5000 per person from all comers until such time as I decide to cut this off. You can place your bet by commenting on this post with the amount you’d care to stake. Be sure to include your email address (which does not show up in the post) so I can email you and verify that you’re for real.

The problem, remember, was this:

I specified that the answer is to be interpreted in **expectation**, since the actual fraction of girls could be anything at all due to statistical flukes.

I say the answer depends on the number of families in the country, but in no case is it 50%. Lubos insists that the correct answer is 50%.

Now the best way to settle such a dispute is to go to the mathematics. But since Lubos seems unable to follow the mathematics, the next best way is to run a simulation. So I propose the following terms: We’ll randomly choose five graduate students in computer science from among the top ten American university departments of computer science and have them write simulations for a country starting with, say, four couples, each having one child per year and stopping when they have a boy. We’ll let this run for a simulated 30 years and then compute the fraction of girls in the population.

[**Edited to add:** If Lubos (or anyone else) prefers to run the simulation till every family is complete (as opposed to a fixed number of years), that's fine with me. The bet is still on.]

To guard against statistical flukes, we’ll run the experiment 3000 times and take the average of all the results.

I claim the answer will be just a hair under 44%. Lubos claims 50%. Let’s say I win if the actual result is less than 46.5% and he wins if it’s greater than 46.5%. (It would be fairer to put the cutoff at 47%, splitting the difference between us equally, but I already offered 46.5% in a comment on his blog, so I’ll stick to that.)

If Lubos — or anyone else — has a better idea of how to choose the programmers, I’m open to adjustments in this procedure. And if Lubos — or anyone else — doubts that the procedure I’ve just described is a fair way to address the original question — namely what, in expectation, is the fraction of girls in the population — we can submit the dispute to five professors of statistics, chosen randomly from the top ten American departments of statistics. Lubos can describe the computation he wants done, the statistics profs can judge which of our descriptions is more appropriate, and the bet will stand with the simulation done as the profs prescribe.

I am guessing that nobody will take this bet, because everybody (including Lubos) who claims to doubt the result is in one of two categories: Either they’re aware that they’ve failed to understand the mathematics, or they’ve understood it perfectly well but are posturing for effect. Either way, I expect they’ll be unwilling to put up any cash. But I hope I’m wrong. I could use the money.

I’ve learned over the years that you shouldn’t bet with someone who knows what the heck he’s talking about and that I don’t know what I’m talking about.:) I’d would rather bet with you than against you.

Could you please be more precise about exactly which computation will be made? For example:

“The ratio of girls to boys in each family (or country?) will be computed by dividing the number of girls by the total number of children (or by the number of boys?) and then the arithmetic mean of all those ratios will be computed.”

I think what you’re intending is something similar to the above, but I’d like to see you confirm before I comment further.

I think the simulation should run until all families have had a boy, instead of just 30 years. The limit of 30 years I understand as a biological limit, which is extranous to the spirit of the problem.

“And no, it’s not wrong because of small discrepancies between the number of male and female births, or because of anything else that’s extraneous to the spirit of the problem.”

Otherwise, it sounds fair to me.

I get 43.9% with four couples. With 100 couples I get 49.7%. This is with 30,000 runs. I didn’t bother with the “30 years” part — you’ll get a boy eventually.

I hope I didn’t ruin your chances of winning $15,000.

“starting with, say, four couples, each having one child per year and stopping when they have a boy. We’ll let this run for a simulated 30 years and then compute the fraction of girls in the population.”

What does “simulated 30 years” mean in this context? Are there only ever four couples having children, and 30 years just means one couple can’t have more than 30(?) kids? Or are you intending second generation children should be involved?`

Jay:

The computation is as specified in the problem: We are computing the expected fraction of girls in the *country*. So if G is the number of girls in the country and B is the number of boys, then we take G/(G+B).

Jonatan: I cut it off at 30 years to make it *harder* for me to win. If you let it run till every family has a boy, my odds (which are already astronomical) will be even better. If Lubos (or anyone else) prefers that bet, I’m definitely in.

Sol: There are only four couples having children in this version. You are welcome to propose an alternative version, but then I get to update my 44% prediction (though it will never go all the way to 1/2).

Yeah, the G/(G+B) was the more obvious part I think, what I was getting at more was confirming that what you want to do is described the following:

1) At the end of each simulation, you have 4 families, each with N girls and one boy.

2) For each family, compute the ratio G/(G+B).

3) Take the arithmetic mean of those 4 numbers. This is the “result” of that run of the simulation.

4) Take the arithmetic mean of the results of all 3,000 simulations. This is the value on which the outcome of the bet rests.

Or, do you mean:

1) At the end of each simulation, you have 4 families, each with N girls and one boy.

2) Add the number of girls in all 4 families to get G. Add the number of boys in all 4 families to get B (which in this case will equal 4).

3) Compute G/(G+B) to give the result of that run of that trial.

4) Same as above.

——

Maybe I’m being too pedantic, but the reason I’m spelling this all out is that I think that underlying much of the debate here is more semantic confusion that you might be aware of (or than you are choosing to let on). Phrases like “expected fraction of girls in the country” are just ambiguous enough that, before proceeding further, we should try to recast everything in the language of mathematics.

If what you mean is the first computation I described above, and your opponent has fully understood exactly what you mean, then you are right and he is wrong. The value from the simulations in this case (essentially, the case in which you use countries of size 1), will be well under 50%.

If, however, what you mean is the second computation, then it’s not quite so straightforward. The expected result of the simulation depends on the number of families–I imagine you’ve evaluated the probability for a country with 4 families, and that’s where you got your 44% value from. But doesn’t the expected ratio still approach 50% as a limit as the number of families grows large? I believe it does, and that makes your assertion that “in no case is the [the ratio] 50%” a bit misleading–the fact that it approaches 50% as an asymptote is highly relevant to a complete understanding of the problem.

Regardless, I suspect that you and your opponent (and many of your opponents on this blog, on this topic) differ more on your interpretation of the question than you do on any serious mathematical point. Maybe you believe that your interpretation of the question is the only sound one based on the language used (I might even agree), but if you make a genuine effort to specify to your opponent _exaclty_ what series of computations you intend to perform and what result you expect, you will be more likely to identiy the source of the disagreement.

Ok so I am in 100% agreement with you that the expected fraction of girls is less than 50% for 4 households. But if you’re planning to do the following procedure (which is what I understood from the post, correct me if I’m wrong) I think you have a fair (even money) game.

1. Take a country of size 4. Run a simulation. I get $1 if we have 50% or more girls (i.e. at least 4 girls). You get 1 dollar if we get 3 or less girls.

2. repeat step 1 1000 times.

Well then we don’t care about the expected fraction of girls. We care about the probability of fraction of girls beign below 50%.

P(3 or less girls)=P(0 girls)+P(1 girls)+P(2 girls) + P(3 girls)

=1/16 + 4/32 + 10/64 + 20/128

=1/2

So I think if he takes the bets on each individual run it’s coin flips.

Yes you’ll certianly (ok Probability 0.999999999999) win if he takes the bet on the average over all of them.

Disclaimer: This was/is a back of the envelope calculation.

Steve: You could be the new Marilyn vos Savant with this problem, only not as good looking :) .

Jay: (Sorry, I posted a response based on a too-quick reading of your comment; I’ve deleted that response and replaced it with the following):

Your first computation computes the expected ratio across *families*. Your second computes the expected ratio across *countries*. The problem clearly asks for the latter.

As for the result approaching 50% as the number of families gets large:

a) Yes, I

pointed this outin the original post.b) The fact that the result happens to approach 50% does

notimply that the “official” argument has any validity. Just because an argument reaches an (approximately) correct conclusion does not mean it’s a valid argument.I stand by my willingness to take your bet and to submit any disputes about alternate interpretations to a panel of statistics professors.

Jonathan Kariv: The problem does not ask for the expected fraction of girls conditional on the population size. Nor does it ask about the probability that the fraction of girls will be less than 50%. It asks for the expected fraction of girls.

I quite agree that if you want to pose some entirely different problem, it might have an entirely different answer.

Edited to add: Jonathan, I now see that you were making a different point than the one I responded to. You are absolutely right and I apologize.Did you see the code written by Lubos? He gets the same result that you expect: http://pastebin.com/nHNLzbPw (but rejects the equal weighing of countries as unnatural).

I’m not conditioning on the population size at all. I’m conditioning on the number of families being 4 (I thought this was what you where proposing for your proposed simulation????).

I’m not arguing about the expected fraction of girls. We’re in agreement about that (as is everyone else sane). I’m saying that that way you have defined the simulation you’re going to a random fraction of girls every time, and that this random fraction will be less than 50% half the time. To be clear I’m talking about the 2nd bet where it’s $5 on each individual run.

.

The problem must be in the definition, somewhere. I wrote

a quick sim, and I get essentially a 50-50 ratio. If a

different sim gives a different result, where do we disagree?

DEFINT I-J

RANDOMIZE TIMER

‘ for 30000 trials

FOR J= 1 TO 30000

F= 0

M= 0

‘ for up to 30 generations

FOR I= 1 TO 30

‘ for each of up to 4 families without male offspring

FOR I2= 1 TO 4 – M

J2= INT(RND(1)+.5)

IF J2 = 1 THEN

M= M + 1

ELSE

F= F + 1

ENDIF

NEXT

‘ end early if we have achieved males in all families

IF M > 3 THEN

I= 32000

ENDIF

NEXT

‘ add to the running count of males and females

TOTM= TOTM + M

TOTF= TOTF + F

NEXT

‘ show the results

PRINT ” MALES=”;TOTM

PRINT “FEMALES=”;TOTF

PRINT “RATIO:”;TOTF/TOTM

SYSTEM

Yup, that’s all clear (sorry about any repetition, there’s starting to be a lot of material to read just on your few blog posts).

I think the fact that 50% is the limit for large n (n being the number of families in a country) has more significance than merely an approximately correct conclusion–a limit is a much more specific and meaningful thing than just an approximation. Moreover, even your wording of the problem in the blue box simply says “a country,” and I think most people would imagine that to include a very large number of families (certainly not a number on the order of 4).

Now, like I said, if you make very clear what you mean to do and he still expects the simulation with n=4 to come out differently, then he’s wrong (which you already know). At point he’s just disagreeing with you on the output of some arithmetic. But I find it much more likely, as I said, the disagreement stems from different interpretations of the question. And I think what might be motivating many of the dissenters here is that they find your interpretation of the question to not be the one that’s most in the spirit of the problem, as it’s usually asked.

In any case, as you say, if you pose a different problem it might have a different answer. I just don’t understand why the opposing factions here don’t turn more attention to the fact that they’re essentially arguing about different problems, rather than arguing about different solutions to one problem.

Ron: How much money you got on you?

Jay: And I stand by this:

Even if you interpret the problem not as an expected ratio but as a limit of expected ratios as k gets large (which is not what the problem asks for, but let’s let that go for now), you still can’t legitimate the “official” argument

even if it leads to the right answer. Theargument, which relies on conflating an expected ratio with a ratio of expectations, iswrong.1st point:

I would think that you would want to be pretty specific/as unambiguous as possible on “expected”. E.g. If the following are the result of 1 run (M-Mother, F-Father, B-Boy, G-Girl):

Family1 – FMB

Family2 – FMGB

Family3 – FMGGB

Family4 – FMB

Expected means 3G/(4B+3G) = 42% and not (4M+3G)/(4F+4B+4M+3G) = 46.6%

2nd Point:

If someone doesn’t buy the mathematics being used, why would they accept that a simulation run 3000 times as being valid.

3rd Point:

I’ll bet thou (Steve L.) $ 3.25 that at least 31.5% of the populations will end up with 2 or less girls. In essence cutting their future population at least in half.

Prof. Landsburg:

Would you loose your tenure if you brokered a bet between Ron and me?

No need for “five graduate students in computer science from among the top ten American university departments of computer science.” The code is pretty simple and if your posters just put the source online, you and your opponent can vet it.

Here is R code (and I didn’t go for elegance):

ratios <- c()

for (i in 1:3000) {

couples <- 4

girls <- 0

boys <- 0

for (j in 1:30) {

new.boys <- sample(seq(0,couples),1)

boys <- boys + new.boys

couples <- couples – new.boys

girls <- girls + couples

if (couples == 0) break

}

ratios <- c(ratios,girls/(girls+boys))

}

mean(ratios)

The limit seems to be around 39.5% girls, BTW. Changing the number of years had almost no effect but changing the population did, as Steve expected. Ten couples converged on 42.1% 100,000 couples 43.5% 1,000,000 = 43.9%

Conclusion: 44% seems right for a large population. I wouldn't take Steve up on his bet if I were you.

If anyone sees any error in my code, please let me know and I'll fix it.

I made a graph of the expected fraction at different population sizes. 3000 simulations for each, 30 max children. (The last factor didn’t make discernible any difference.)

http://dl.dropbox.com/u/15689398/fraction.png

Jonatan: Your graph appears to coincide exactly with what the mathematics predicts. If it had differed, I’d have bet on the mathematics.

I’m willing to take the bet if the total number of children born in the country is capped at 4.

Ben: Very cute.

Neverfox:

The code is pretty simple and if your posters just put the source online, you and your opponent can vet it.That only works if my opponent is a) honest and b) competent. The Internet, however, harbors all sorts.

I did make a mistake in the code by assuming a uniform distribution of odds for the outcomes of the remaining couples. When I fixed it, the ratio was 44% for your 4-couple example but converged *close* to 50% in large samples but not quite there. Therefore, I confirm Jonatan’s results, at least in spirit.

@ Neverfox:

”

Changing the number of years had almost no effect.

”

You should take Ben up on his bet of capping the population at population at 4. In essence, this is setting the number of years to 1.

@ Ben:

A genius can say “Very cute”. My comment is very cool. Thanks for making me look at that and therefore the deeper understanding.

To guard against statistical flukes, we’ll run the experiment 3000 times and take the average of all the results. Or, if Lubos prefers, we can ***bet $5 separately on each of 3000 runs***. (And, similarly, anyone else who wants to bet, say, $3000 can bet either $3000 on the average or $1 on each run separately.)

Here is my code

girls<-0

ratio<-(1:3000)*0

for (i in 1:3000)

{girls<-sum(rgeom(4,0.5))

ratio[i]<-girls/(girls+4)

}

sum(sign(0.44-ratio))

Can someone explain why the final number this spits out is not the payoff of the 2nd bet (the seperate one which I put stars around), that Landsburg is suggesting. He's obviously right about the original question as to what the expected value is but unless I'm interpretting something really really wrong (possible but checked repeatedly) THE SIMULATION he's proposing is going to give 3000 fair coin flips. Which isn't a bet worth taking for either party.

I guess I'm asking why he objects to the above code for the simulation he's making a bet on?

Aha! Got it! Looking at Neverfox’s code, I see what I’d

been missing in mine. The end of the program should have

been:

‘ add to the running count of males and females

TOTM= TOTM + M

TOTF= TOTF + F

‘ add to the running ratio figure

CURRATIO= F / (M + F)

TOTRATIO= TOTRATIO + CURRATIO

NEXT

‘ show the results

PRINT ” MALES=”;TOTM

PRINT “FEMALES=”;TOTF

PRINT “FEMALE FRACTION:”;TOTF/(TOTF+TOTM)

PRINT “MEAN FRACTION=”;TOTRATIO/30000

SYSTEM

At which point, my results all come into the ballpark of 44% female fraction.

So, sorry, no bet against Landsburg.

Before you make your $15K bet, be sure to nail down your

definitions. While the 4-family problem gives a mean ratio

of 44%, the median value of those ratios is 50%.

Ron: The phrase “in expectation”, by definition, refers to the mean.

Can we wager any amount less than 5 grand? You did say “up to”. Can I that is wager a negative amount so that should Landsburg be correct (and he is) he must pay me? If so, I’m in for ten bucks.

@Steve: this is all very droll, but it is a very interesting question why so many cling so tenaciously to the “aha” of the intended solution.

Ken B:

it is a very interesting question why so many cling so tenaciously to the “aha” of the intended solution.I think in many cases, it’s because they simply haven’t bothered to read the explanation, because their priors are so strong.

But there’s also this:

1) The “official” solution relies on the following (false) lemma: “If the expected difference is zero, then the expected ratio is one”.

2) I gave, in the “Big Answer” post, an explicit and simple counterexample to that lemma, involving four families on my block.

3) Many responded: “But that counterexample is not at all like the problem!” E.g, it’s about families instead of countries, etc.

4) So here’s the precise thing these people weren’t getting: If I can give you

any counterexample at allto your lemma, your lemma is invalidated, and if your lemma is invalidated, then so is your whole argument. Itdoesn’t make a bit of differencewhether my counterexample resembles your original problem.5) And

that, I think is the very simple logical principle that has gone over some people’s heads.6) I understand that this result is counter-intuitive. I understand that some very smart people get it wrong at first, and that some very smart people need a long time to digest it. The ones who seem to me to be beyond the pale are those who keep repeating the same irrelevant arguments (e.g. “But there are the same number of boys as girls on your block!” after the specific irrelevance of those arguments has been explained to them 62 ways. Those, I think, are the unserious ones.

In all honesty, Steve, I think it is a matter of differing ways of interpretating your example. Your original question asked about the expected proportion of girls in a country. In your “families in a block” example, a reader could reasonably identify a country with a block, rather than a country with a family. Most people think of countries as collections of families.

If one does identify a country with a family, then your answer is clearly correct. But if one identifies a country with a block, a collection of families, then the answer is different. For example, there may be four blocks, exactly like yours, with 12 girls and 12 boys in each. If you ask, what is the expected proportion of girls in a country and I identify country as meaning a block of families, then the answer is 50%.

This answer above, strictly concerns your example where there are equal numbers of girls and boys in the block, not the general problem, although the family-country ambiguity applies there too, so I am guessing no one can really win or lose this bet.

@Steve:

I have also noticed a few posters who argue like this:

1. It is exactly 50%

2. No, look at your example, this other number is 50%

3. OK then, it approaches 50%. That’s what I meant all along.

4. Plus the difference doesn’t matter. Actually 50% is a better answer even if it’s not exactly right.

I am not making #4 up, as one can see from the previous thread.

You are right about strong priors but why would anyone have those about a puzzle? This is not remotely as surprising as the Monty Hall problem, where a perfectly normal seeming inference in a normal sounding situation is wrong: this is a solution to an outre puzzle that you have to think about to get. (In Monty Hall most react without thinking.)

@Neal:

Nope. In that example the distribution of families on his block does not match the expectation. Of course if you are allowed to specify what children are born to whom then you can create special cases where the result is 50%. Just as one can construct examples where the ratio is 0%. Examples cannot prove a claim, but counterexamples can disprove it.

I haven’t followed all of the exchanges on this, but I thought I’d point out that there’s some pretty serious research out there that’s based on Steve_Landsburg being right (or at least, the answer being less than 50%).

Robert Wright’s

The Moral Animalgives an example of a success from evolutionary psychology: EvoPsych theory predicted that poorer women would behave as if they “keep trying to have children until they get a girl”, and wealthier behave as if they “keep trying to have children until they get a boy”. Then, they looked at the data, and that turned out to be true (in the statistical sense, obviously — it’s not that all poor women act one way, etc., just that it’s true on average)If the official answer is correct, that would imply that there would be

nosex difference from such a selection method, and therefore no tendency for women to do this, and thus no difference in gender ratios in the populations researched, contradicting this published EvoPsych result.If anyone is interested in the significance of the answer of this problem to this result in the literature, I’ll dig up the cite.

Steve: I assume that Lubos isn’t going to take your bet, and I’d like to see my fellow posters learn something from you without having to pay some amount of money up to $5000. (I’d prefer they simply buy your next book instead.) Of course they are free to do as they please, but here is some code they can use if they have access to Matlab or something like it:

–

K = 3000;

N = 4;

P = 0.5*ones(K,N);

N_girls = sum(geornd(P),2);

N_boys = N*ones(K,1);

N_children = N_boys + N_girls;

Proportion_girls = N_girls./N_children;

overall_result = mean(Proportion_girls);

Landsburg_wins = sum(Proportion_girls < 0.465)/K;

–

The overall_result is the average proportion of girls in the country. Here are some numbers for various simulations with 3000 trials each:

0.4387; 0.4447; 0.4388; 0.4380; 0.4382; 0.4362; 0.4346; 0.4421; 0.4379

I think you are sticking it to Lubos by setting the threshold at 0.465. However, if I understand your alternative bet correctly, you shouldn't offer the $5 wager on each of the 3000 runs. Here are the proportion of wins you would have for several of my 3000 run examples (as assigned to the variable Landsburg_wins in my code):

0.4880; 0.5023; 0.5027; 0.5080; 0.5107; 0.4923; 0.5050; 0.4973; 0.4957

Heck, you wouldn't win nearly as much money, and there is a reasonable chance that you would actual lose a little. (But maybe I'm misinterpreting this part of your proposed wager.)

I apologize if this causes anyone to forgo a bet with you who might have done so otherwise. I'm not a PhD student in computer science at one of the top 10 departments, however, so there is a chance my code is faulty. Still, I'll have no sympathy for anyone who loses money to you after reading this post.

For the special case of 4 families, I confirm that simulation produces 43.9%. No one should accept the bet at even odds.

For the general case of k families, my simulations confirm the approximate Douglas Zare result of 1/2 – 1/4*k. I tested this on selected values of k up to 128.

One can recognize that one-boy-land resides in the special universe of small countries like Lewis Carroll’s Wonderland, and thus consider special cases of 4 families to be relevant.

Google, however, is operating in a 21st century reality where the median country has over 5 million citizens, or over 1 million families. Only a pedant would dispute the equivalence of 0.50 and 0.49999975. Any glance at Google search results will show that Google is more interested in an answer that is approximately correct than one that is precisely pompous.

I humbly submit, based on the evidence, that Google would not hire Mr. Landsburg.

FWIW, here is the correction I made.

Replace: new.boys <- sample(seq(0,couples),1)

With: new.boys <- sum(sample(c(0,1),couples))

Oops! I typed it incorrectly in the post. That should read:

new.boys <- sum(sample(c(0,1),couples),replace=TRUE)

Michael:

As I’ve pointed out to several other posters, the issue with these problems is not just getting the right answer; it’s getting the right answer for the right reason. For a large country, 50% is, for all practical purposes, the right answer (though still not exactly) —- but that

doesn’t make the usual argument correct. The usual argument is still flat out, unequivocally wrong.Thomas Bayes:

I believe I’d still win betting on 3000 separate runs, but I’ve withdrawn the offer to separate them. I think it’s cleaner to have one conclusive bet.

Here’s how a computer scientist would solve the problem:

https://gist.github.com/757093

I always get 50% independent of initial population size, so I expect my interpretation is the same as Google’s.

I’ve read the comments on yours and Lubos Motl’s blog. From a rationalist viewpoint we have achieved the optimal outcome since you both seem to agree that the other person is right if you accept their assumptions about how to mathematically interpret the problem.

Since Motl is a string theorist at Harvard did you ever really think that the reason he disagreed with you was because he wasn’t able to follow the math?

I wrote a column for GammonVillage.com (subscription required to read it, sorry) on this puzzle, and some applications to backgammon. Here is one of them:

In your backgammon club, there are 8 equally skilled players who play a single-elimination tournament each week. At the end of the season, you compute the winning percentage of each player. Although your chance to win each match is 50%, your expected winning percentage is below 50%, and it is very common for the average of the winning percentages of the club members to be below 50%, even though they played against each other. The players who won a lot tend to have played more matches, so wins are weighted less heavily than losses.

In that situation, each person corresponds to a country, and each week’s result for a person corresponds to a family in the country, although it would be a family which stops at the third child regardless of whether the third child is a boy.

Reading the question in the box, and the part you added about expectation, I fail to see why you claim the following is an invalid interpretation of the question:

Fraction of the population is G/(G+B). But we are asked for the expectation. So compute E(G) = expected number of girls and E(B) = expected number of boys. Then the fraction of the population that is female, in expectation, is

E(G) / ( E(G) + E(B) )

Now, if the question has specified the expected value of the fraction of girls in the population, then I would agree that your interpretation is the only reasonable one. But you did not specify that.

Even worse, the google interview question does not specify anything even close to that phrasing. Worse still, no reasonable person would care about the expected value of the fraction of girls in the population for a country. Therefore, it is ludicrous to claim that the answer of 0.5 to the google interview question is wrong.

Of course, the problem is so sloppily written that any answer from 0% to 100% is possible.

The problem doesn’t consider the number of old maids or bachelors, yet asks for the fraction that is female. Nowhere does the problem (or the proposed solutions) deal correctly with the genders of those who aren’t offspring, not even if you presume that couples compose the entirety of the population.

The limiting cases are possible with entirely female or male populations, which have no hetero couples.

The fix to the problem is to specify that you’re interested in the fraction of the population of offspring.

@Steve: For the record, I didn’t want to change the rules, just clearly establish what they are so I could write a computer program. I won’t report my results because I don’t want to stop people from taking your bet…

Dear Mr. Landsburg,

Does one get anything if they agree with you? To me, your problem is a well defined problem and I have solved it explicitly below for towns of family size n =1 and n=2 and I get the answers 30.68% and 38.62% respectively. I have explicitly written the sample space, probability measure, random variables and expectations. I hope that this will provide clarity to the situation and remove the need to run any simulations.

For simplicity, lets say the town has only one family.

Now the sample space here is S = (B, GB, GGB, GGGB,…)

the probability measure is M = (1/2, 1/4, 1/8, 1/16…)

The random variable is F : S -> R is (0, 1/2, 2/3, 3/4 …), i.e. the fraction of town that is female.

So the question is what is mean of this Random Variable.

E(F) = 0.1/2 + 1/2*1/4+ 2/3*1/8 ….

=Sum[(n - 1.)/(n*2^n), {n, 1, Infinity}]

= 0.306853

and we get Landsberg answer

Now suppose the town has 2 families then assuming independent draws, the sample space is

S’ = SxS

= (B,B) (B,GB) (B,GGB) (B, GGGB) (B,GGGGB) ………..

(GB,B) (GB,GB) (GB,GGB) (GB, GGGB) (GB,GGGGB) ………..

(GGB,B) (GGB,GB) (GGB,GGB) (GGB, GGGB) (GGB,GGGGB) ………..

(GGGB,B) (GGGB,GB) (GGGB,GGB) (GGGB, GGGB) (GGGB,GGGGB) ………..

(GGGGB,B) (GGGGB,GB) (GGGGB,GGB) (GGGGB, GGGB) (GGGGB,GGGGB) ………..

.

.

.

.

Probability measure is M’ = M*M

The random variable, fraction of girls in town, is F’ =

= 0/2 1/3 2/4 3/5 4/6 ………..

1/3 2/4 3/5 4/6 5/7 ………..

2/4 3/5 4/6 5/7 6/8 ………..

3/5 4/6 5/7 6/8 7/9 ………..

4/6 5/7 6/8 7/9 8/10 ………..

.

.

.

.

So finally, the Expected fraction of girls in town:

E(F’) = 0/2*1/(2^2)+1/3*1/(2^3)+ 2/4*1/(2^4)+ 3/5*1/(2^5)+ 4/6*1/(2^6) ………..

+ 1/3*1/(2^3) + 2/4*1/(2^4) + 3/5*1/(2^5) + 4/6*1/(2^6) + 5/7*1/(2^7) ………..

+ 2/4*1/(2^4) + 3/5*1/(2^5) + 4/6*1/(2^6) + 5/7*1/(2^7) + 6/8*1/(2^8) ………..

+ 3/5*1/(2^5) + 4/6*1/(2^6) + 5/7*1/(2^7) + 6/8*1/(2^8) + 7/9*1/(2^9) ………..

+ 4/6*1/(2^6) + 5/7*1/(2^7) + 6/8*1/(2^8) + 7/9*1/(2^9) + 8/10*1/(2^10) ………..

.

.

.

.

= Sum[Sum[(j - 2.)/(j*2^j), {j, k, Infinity}], {k, 2, Infinity}]

~ 0.386294

So there.

The answer is not 50% for n=1 and n=2. I am sure it would be relatively painless to generalize this to n=k and maybe even find some bounds for all n.

Cheers,

Anshuman

I have a minor typo in the above comment. It would be great if you could edit it. When I wrote “towns of family size n =1 and n=2 ” I meant to write “towns with one or two families”.

Thanks,

Anshuman

Came here from Tyler Cowen and I read through the posts and their comments and this is, for me at least, actually a really interesting problem. And the interest part of it is how the concepts relate to the math, not the math itself.

I think the official answer is right, or at least the correct answer in the spirit of the problem. I think JamesL’s comment on the last post summarizes where I am, and I hope Steven can address that a little more.

Let’s concede that E[G/(G+B)] != E[G]/E[G+B] and and all the rest of it. Why should we think that’s important? As I think of it, a country has an arbitrarily large number of families and the fewer families with more girls make up the percentage by having more children in total? Why should we consider these second or third order differences and but think that it’s irrelevant that girls are 53.444% of live births in Australia (or whatever)?

I don’t your wager helps much either. As a thought experiment (or an actual one), let’s say that the country was Australia? What should we expect the female percentage of Australians?

Erik R:

Fraction of the population is G/(G+B). But we are asked for the expectation. So compute E(G) = expected number of girls and E(B) = expected number of boys. Then the fraction of the population that is female, in expectation, isE(G) / ( E(G) + E(B) )

Suppose I ask you for the expected number of hermaphrodites in this country. That’s the expected number of people who are both boys and girls or E(BG). Would you compute that by calculating E(B)E(G)?

A question that the answer will tell you which solution is correct:

Is country defined as a fixed number of families or a number of people?

If it is number of people 50% will always be correct.

If it is a number of families, Steve’s solution will be correct. The subtlety is that when you are doing the expectation, you are comparing countries with different numbers of populations, and the ratio is biased with countries, such that larger countries have a higher number of girls, so on average girls count for less when you average the counties girl fraction (and divide by number of countries, not total population).

A better way of phrasing the question would be what is the expected girl fraction in a suburban cul-de-sac.

Koz: I’ve said this several times in comments, but will say it again: You can call the difference in the

numerical answersmall, but that doesn’t change the fact that the originalreasoningis wrong. You don’t get credit for the right answer if your reasoning is wrong.Suppose someone says: Well, there are exactly two genders, so of course the answer must be 50% !. Would you say that he’s corrrect to second or third order so we should accept his answer?

James D. Miller:

I’ve read the comments on yours and Lubos Motl’s blog. From a rationalist viewpoint we have achieved the optimal outcome since you both seem to agree that the other person is right if you accept their assumptions about how to mathematically interpret the problem.That’s not at all what’s happened.

What happened is that:

a) Lubos got the problem wrong

b) When he realized that, he invented a new interpretation to make himself right

c) Having invented that new interpretation, he then accused

meof changing the problem midstream — because I am insisting on sticking to the original problemd) He compounded his dishonesty by reproducing the GIF stating the problem from the original post while refusing, repeatedly, to acknowledge the surrounding text specifying unambiguously how the problem was to be interpreted

Since Motl is a string theorist at Harvard did you ever really think that the reason he disagreed with you was because he wasn’t able to follow the math?I’ve given the Monty Hall problem to some of the best mathematicians in the world, and they’ve gotten it wrong. Some of them insisted on the wrong answer for days before they got it. The difference between them and Lubos is in their ultimate reactions: “Wow, I get it now!” versus “But I gave the correct answer to this *other* problem, and you cheated by not asking me the question I knew how to answer”.

With only a minimum of contrariness, I don’t buy this. You’ve written several times that there is no plausible formulation of the problem where 50% is the correct answer.

I disagree. If we assume that a country has an arbitrarily large number of families (and the we calculate the percentage of females by multiplying the percentage of female children per family times the number of children in the family), then the answer is 50%, for exactly the “official” reason. Do you dispute this?

That strikes me as a very reasonable assumption, and much better than saying a woman can have infinite children or that p(g|birth) is exactly 50% or any other assumption required to reduce the problem to that particular statistical exercise.

Koz:

I disagree. If we assume that a country has an arbitrarily large number of families (and the we calculate the percentage of females by multiplying the percentage of female children per family times the number of children in the family), then the answer is 50%, for exactly the “official” reason. Do you dispute this?This is correct in exactly the same sense that if we calculate the percentage of females by defining it to be the number of left shoes in the country divided by the total number of shoes, we will get 50%. You’ve managed to come up with a completely irrelevant calculation that gives you the answer you wanted. So what?

I guess I don’t see the irrelevance, given the original problem as stated and how we should reasonably interpret it. Why are you taking this to be irrelevant?

Prof. Landsburg, Koz is right. In a brainteaser, it’s eminently reasonable to assume an infinite population, while your solution requires us to assume some unspecified but finite initial population. Neither your initial highlighted text nor the clarifying paragraph below it mentions this; you only mention it in your third post on the subject, where you specify an initial seed population of 4 couples.

asdfasdf:

In a brainteaser, it’s eminently reasonable to assume an infinite population, while your solution requires us to assume some unspecified but finite initial population.In an infinite population, what sense can you possibly make of the “fraction that is female”? Infinity-over-infinity?

your solution requires us to assume some unspecified but finite initial population…you only mention it in your third post on the subject, where you specify an initial seed population of 4 couples.I guess, then, that you never read the first two posts, where I gave the explicit calculation for a population of 1 couple and explained how the answer varied with the number of couples k.

But if you think that’s what the original post said, fine. Take my bet. If a panel of statisticians agrees with you, you win $5000. Are we on?

I never thought it made sense to have 3000 seperate bets. The question is about the expected fraction of girls in the population, not about the expected fraction of populations where the fraction of girls is more than some value.

But if we assume that the question is instead: What is the chance that this population will have 50% or more females?

The answer to this question is 50%.

I agree with everything that you are saying, but it is interesting to note that we readily assume that the possible number of girls born to one family is unbounded, yet we also assume that the number of families in the country is finite. It is enough to hand wave a little about the former (e.g. it is implied when we say “assume the basic stuff like 50/50 chance of a girl, etc.”), but if one wanted to get the 50% final answer, one would need to explicitly deny the latter (e.g. state in the question that we want to know the expected ratio of girls to boys as the country’s population approaches infinity).

So a more charitable interpretation of people who think that the answer is 50% is a third possibility (to add to your 2 above): they are just assuming that the question is asking what the ratio is in the limit as the size of the country goes to infinity.

Jonatan: When I first offered 3000 separate bets, my intention was to weight the payoffs according to the outcomes (so, using 47% as the average of our predictions, you give me a dollar when the outcome is 46%, you give me two dollars when it’s 45%, I give you a dollar when it’s 48%, I give you two dollars when it’s 49%, etc.) I toyed with various ways to state this, some of which were too complicated and some of which were too oversimplified. In the end, it seemed easier to just delete this option.

Nick:

So a more charitable interpretation of people who think that the answer is 50% is a third possibility (to add to your 2 above): they are just assuming that the question is asking what the ratio is in the limit as the size of the country goes to infinity.But when you look at their

reasoning, which still relies on conflating an expected ratio with a ratio of expectations, it’s quite clear that this is not the assumption that’s driving their results.Ah okay. Makes sense.

I mostly posted because I thought it was interesting that the answer to this other question is 50%.

I tried this before, but I’ll try once more for those of you who think it is ‘silly’ to place importance on the 1/K term and the way it came about.

Suppose you flip a fair coin K times and count the number of times you see ‘heads’ and the number of times you see ‘tails’. What is the expected value of the product of the proportion of times you see heads times the proportion of times you see tails?

Answer 1: The expected proportion of heads is 1/2 and the expected proportion of tails is 1/2, so the answer must be 1/4.

Answer 2: Because this problem involves a product instead of a ratio, it is relatively easy to compute an exact answer for the question, and that answer is 1/4 – 1/(4K).

Answer 1 is wrong, and the fact that 1/4 is close to 1/4 – 1/(4K) for large K doesn’t make it correct, or even close to correct. If you asked someone this question during an interview, and you were trying to determine if they understood how to properly manipulate expectations, then you should not accept answer 1 as correct. There is a fundamental flaw in the answer.

@ErikR:

The fraction of the population is g/(g+b). Agreed? We seek the EXPECTATION of this. We write that E(g/(g+b)). Agreed? But that does not equal E(g)/(E(g+B)). It just does not. E is a summation of terms, and the sum of a fractions is not the fraction of the sums. So the proposed answer is just based on a mistake.

Jonatan:

–

But if we assume that the question is instead: What is the chance that this population will have 50% or more females?

The answer to this question is 50%.

–

This means that there is a less than 50% chance that there are more females than males, and a greater than 50% chance that there are more males than females.

“In an infinite population, what sense can you possibly make of the “fraction that is female”? Infinity-over-infinity?”

Is the probability that a “random” integer is odd unknowable? Or is 1/2 a perfectly valid answer due to sensible combinatorial and/or asymptotic considerations?

–

Is the probability that a “random” integer is odd unknowable? Or is 1/2 a perfectly valid answer due to sensible combinatorial and/or asymptotic considerations?

–

You need to specify a distribution. After you do that, the probability that the integer is odd will either be 1/2 or it won’t. There is nothing asymptotic about it.

Thomas Bayes > Yeah. It requires that ties goes to the females.

“You need to specify a distribution. After you do that, the probability that the integer is odd will either be 1/2 or it won’t. There is nothing asymptotic about it.”

Uniform distribution, of course. Of course a uniform distribution on the set of integers doesn’t make sense, which is why most people would do something like consider the uniform distribution on {-N, -N+1, …, N-1, N} and take N -> infinity.

The point is that there are often perfectly sensible ways of handling probabilities on infinite spaces.

Steve:

As you point out, it is important to get the right answer for the right reason. I don’t believe your reasoning is fully correct because it makes two faulty assumptions.

1) That the sex ratio is measured when all families are complete.

2) That the solution for a single generation is equal to the solution for an equilibrium population.

Below is my improvement on your solution, which I now accept in principle:

Each birth cohort at every time t can be assumed to have the natural sex ratio of the population, P. For simplicity, we can assume that P = .5, although this is not necessary.

If we assume (incorrectly) that the number of births at time t+n is independent of the actual sex ratio at time t, then we naively arrive at the (incorrect) solution of 0.50. [This is the mistake I made when arriving at the simple solution.]

We observe instead that a low actual proportion of girls at time t results in a relatively lower number of births at time t+n, thus preserving (on average) the low birth ratio for girls. Likewise, a high proportion of girls at time t results in a relatively higher number of births at time t+n, thus diluting (on average) the high birth ratio for girls. In each case, the pattern eventually favors a low expected aggregate birth ratio for girls.

It is the realization that the number of births at time t+n depends on the observed sex ratio at time t, that yields the path to the correct solution.

It is important to note that even with a large initial population, a multi-generation simulation of this puzzle will tend to produce a shrinking population, with resulting lower expected sex ratios of girls at each subsequent generation. Every such simulation will eventually terminate with a single male offspring and no mate.

So,

1) The answer is always less than the natural proportion P.

2) The answer depends on the number of families and is lower with fewer families.

3) 1/2 – 1/(4*k) applies only to a single closed generation, but is not a general solution.

4) There is no equilibrium solution as there is no stable population. Lacking immigration, any assumptions regarding mortality (>0) and sex ratios (<1) will have a terminal result of 1 male offspring and no mate.

Is there any way for someone who agrees with you to make money on this? If you get too much action and exceed your credit limit, drop me a line. :)

I’m a stat prof. I have not read all the comments. You state one problem in your highlighted text box and then present the mathematics for a different problem. The problem asks about the proportion in the POPULATION, but your analysis pertains to the average ratio WITHIN FAMILIES. Those are not the same thing so it is not surprising that different people are getting different answers. Your statement of the problem does not say which you are calculating.

If your analysis was correct for the population, then it implies the following sure-win strategy for roulette: bet $X on red. if you lose, double your bet to make up for the prior losses and bet on red again. continue doing this until you win on red. leave that table and go to another table where you begin again with betting $X on red. continue the strategy. according to your analysis, there should be a proportion of wins than losses, so your net expected value from this betting strategy is positive, in fact a lost positive. those wanting to bet should go to a legal gambling establishment and try this strategy.

I’ll bet $500.00 provided that Prof. Landsburg stipulates that the 8 parents count in “population” and the 4 mothers count as “females” or “girls”.

Larry:

I’ll bet $500.00 provided that Prof. Landsburg stipulates that the 8 parents count in “population” and the 4 mothers count as “females” or “girls”.I accept your terms.

mtnMan:

If your analysis was correct for the population, then it implies the following sure-win strategy for roulette:Only if G/(G+B) is a martingale. Do you think it’s a martingale?

I think the short explanation should be : if a couple

was to breed an infinite number of children, half of

the kids would be girls. Yet if the couple stops as soon

as it gets a boy, it never gets more than

one boy, whereas it could have many girls. The fraction

of girls thus has to be larger than one half (the fraction obtained

when it never stops breeding) … The couple just does not leave

much chance to boys !

the fraction of girls is 1+2*(0.5-log(2)) …

mtnMan >

His analysis is about the proportion of all the children in the population. Why do you think it’s about the ratio “within families”?

The system you are describing is the Martingale system, right?

(http://en.wikipedia.org/wiki/Martingale_%28betting_system%29) Why does an answer for this question imply that the Martingale system works?

I think you are going to want a lot more than 3000 runs averaged out. There is going to be a huge amount of variation with that low of a number. Enough variation that with 4 runs, you stand a very good chance of losing despite your math being correct.

The original question asking about the fraction of the population (implied to be within an entire country) is always going to be approaching 50/50 in a large enough country (millions or billions of people). It’s both simple math and born out in census data from around the world when the probability of any one child being male or female is 50:50, that same probability will hold for the entire population regardless of how each individual family unit is limited.

You can get slightly skewed demographics when a government incentivizes having a child of one sex over another because a certain percentage of parents can/will kill a newborn of the “wrong” sex.

But in the end, the sex of the “next” baby born is always 50/50 for boy or girl. The only way the problem doesn’t approach 50/50 split is to place small limits on the size of the population. 50% of families that have children in a fashion described in the original problem will just have 1 boy. The other 50% of families will be split between groups having (in descending order of likelihood) only 1 girl, 1 girl and 1 boy, 2 girls and 1 boy, 3 girls and 1 boy, etc. But it all just keeps approaching 50% on a large enough scale.

–

Larry:

I’ll bet $500.00 provided that Prof. Landsburg stipulates that the 8 parents count in “population” and the 4 mothers count as “females” or “girls”.

I accept your terms.

–

Steve, are you sure about this? If I understand this correctly, each of the 3000 countries will have 8 males and a number of females equal to 4 plus the sum of 4 geometric random variables. If so, this seems to push the average proportion of women up to a little below 48.5%.

Are those simulations considering the 8 parents? The question CLEARLY asks about the popluation not just the children.

mtnMan:

Besides the martingale issue, here is another problem with your suggestion:

Suppose there was a game where you draw a random number from a uniform distribution on the interval 1 to 9, and the house draws another that is independent of yours, but uniform on the interval from 1 to 10. You bet that your number is larger or smaller than theirs.

The expected value for the ratio of your number to theirs is about 1.28, but I don’t think you could make much money betting that your number would be larger than the house’s. The expected ratio of the house’s number to yours is about 1.5, but I don’t think that should cause you to take even odds that the house’s number will be 40% larger than yours.

Again, the flaw most people are making is in trying to interpret the expected value of a ratio in a way that just doesn’t work. Having the expected value of ratio be larger than one does not imply that the ratio is more likely to be larger than one than it is to be smaller.

As an example of how this problem still yields a population with 50% of children being born male and female.

Sample population of 1000 families having children. We will assume that half of all families will continue having children after each child born (if they are allowed to under these rules).

500 families have a first born male

250 families have a first born female (1 female) and stop

125 families have a female and then a male (1 female, 1 male)

125 families have a female and then another female (2 females)

If we keep those 125 families going…

62 of them stop having children at 2 females

31 of them have a male (2 females, 1 male)

31 of them have another female (3 females)

If we keep those 31 going…

15 of them stop having children

8 of them have a male (3 females, 1 male)

8 of them have another female (4 females)

At this point, of our 1000 families we have the following breakdown:

500 families with 1 male

250 families with 1 female

125 families with 1 female, 1 male

62 families with 2 females

31 families with 2 females, 1 male

15 families with 3 females

8 families with 3 females, 1 male

8 families with 4 females

This yields a population with (500+125+31+8) or 664 male children and (250)+(125)+(62×2)+(31*2)+(15×3)+(8×3)+(8×4) or 662 female children (or nearly 50/50 and probably off because of my rough rounding.

The point being that regardless of how big any families is with girls (even 15 girls), the next child that they have is 50/50 to be a boy so the overall population dynamics never change.

Prof Landsburg: Great! Please contact me via email and I’ll provide any necessary other contact information to coordinate things.

@ Steve:

I’ll bet provided that you stipulates that the 8 parents count in “population” and the 4 mothers count as “females” or “girls”.

Andwe use 44.4444444444443% as the percentage which is clearly larger than (1/2 – 1(4*4)) = 43.75%The bet would be for $ .01 per country drawn. E.g. if only 40% are above 44.4444444444443% you would get $ 18.00 and I would get $ 12.00. You get a net $ 6.00.

This may be just be me being wickedly stupid, but (like many others!) I implemented it myself.

Prof. Landsburg stipulates to the 500$ bet if the parents count in the population – but if I do this, my simulation doesn’t give the 44%, I get about 49.4%.

Without the parents, I get the expected 44% average.

(This is with 4 couples, 30 years and 4000 iterations. I add the percentage for each iteration, dividing it by the number of iterations)

It would seem like this makes sense – by adding a constant to both the boys and the girls would change the ratio somewhat. 1 boy and 3 girls would give a ratio of 1/3 but adding the parents would give us a ratio of 2/5.

So – did I completely miss the point somewhere? :/

I’d even be willing to increase the percentage to 44.4444444444444%

i’d be willing to bet $50 against you if Lubos takes the $15,000. you have my email address.

Paypal will serve as the intermediary. I also think in the spirit of things, there should be a finite cap on the # of children one can “pump out” so to speak.

Thanks

Here’s why this is different than the Martingale problem:

The countries are not weighted by population size. Use the one-family model as an example: the most likely outcome, overwhelmingly, is one boy; therefore, the most likely outcome for a ‘country’ is to have more boys than girls. It is possible for a country to have ten, or twenty, or an infinite number of girls and only one boy; however, we are only looking for an *expected fraction* in the one hypothetical country. The situation with lots of girls also has a high denominator, but that does not make it more powerful, given the way Landsburg has framed the problem; no matter how many children there are, it is only one possible outcome for a country.

On the other hand, the Martingale problem DOES weight by the size of the ‘population’ (in this case, the size of the bet). With Martingale, you’re more likely to win than lose, but you’ll lose a very large amount if you do.

In the children example, each possible outcome only counts as one outcome, regardless of how many children (“how much you lose by”). So in the long run, the ‘expected fraction’ will favor boys, even if the total number of boys and girls seen is even.

Imho, this thread is going out of control… I always tought that, at least in the field of mathematics, people should reach a point where all agree on some things to be true or false. Especially for not-too-complex problems. Clearly, this is not the case.

The problem? It is clearly at the origin: the problem stastement is somehow ambigous because its description lacks of the needed details.

This situation is similar to what happens in Software Engineering. There is a phase called requirements analysis that is essential in order to write good software.

Now, the main thread plus all the comments plus other blogs threads/comments is a rough “requirements analysis” (problem understanding), but, at least to me, the fact that someone is still betting on this or that way to solve the problem is a clear sympton that there isn’t really a large agreement on the exact problem that needs to be solved…. :)

If you count the parents (technically, they

arein the population), then I agree that Steve would lose the bet if all else stayed the same (including his cutoff offer of 46.5%).You wrote in response to my comment “That’s not at all what’s happened.

What happened is that:

a) Lubos got the problem wrong

b) When he realized that, he invented a new interpretation to make himself right”

In his original post Motl used the problem to discuss weighting issues in the anthropic principle in a way that’s consistent with the interpretation he ends up using so I don’t think you can reasonably infer that he invented a new interpretation in response to your comments. If he always had your interpretation I don’t see why he would have used the question to discuss the anthropic principle.

It was unreasonable, however, for him to accuse you of coming close to cheating since the computer algorithm you effectively proposed to settle the bet was a reasonable way of interpreting the question.

@ Steve:

Sorry for my previous post, I should have said 46.6666666665%. I primed my countries with 1 mom and dad. I should have primed it with 4 moms and dads.

Why start with “say 4 four couples” in the simulation?

Doesn’t that seem like a small number to you?

Might explain why you don’t have many takers. Most of the people who disagree with you think the answer approaches 50% the more couples you have.

Larry wrote:

And I responded:

I accept your terms.This was obviously reckless on my part, as Larry will, in expectation, win this bet as stated.

I’ve specified several times in this thread that if people want to change the setup (by changing the number of families or making other tweaks to the assumptions), then I would still take the bet subject to reserving the right to adjust my prediction (and hence the cutoff between winning and losing bets). I was assuming that, since that reservation had been stated several times, it was still in force. But it’s probably not reasonable for me to assume that Larry had read all those previous comments.

So Larry, I leave this up to you. I made a mistake by accepting your modified bet without specifiying that I had a modified prediction in mind. If you’re willing to release me from the bet for that reason, I will commend your graciousness. If not, the bet is on and I will probably lose.

This of course in no way affects my willingness to take on any and all comers on the originally stated terms.

No, the question concerns the fraction of the population that is female. Then Steve adds that he is asking for expectation. Since

E(G) / E(G+B)

involves fraction of the population, and expectation, it is a perfectly reasonable translation of the problem from English to mathematics. Moreover, it is the most reasonable interpretation of the original google interview question.

Interpreting the google interview question differently as the expected value of a ratio is just a mistake. Posturing in order to try to appear superior. If that’s what floats your boat, then I’ll leave you to it.

On the other hand, if you are interested in informing people on the difference between expectation of a ratio and ratio of expectations, then I think a different question is better. Zare mentioned a backgammon single elimination tournament where this concept comes up. If Steve had started with that, I think this whole discussion would have been a lot more interesting.

I don’t think I was modifying the bet as much as seeking clarification on the meaning of the terms “population” and “girls”.

I have some thoughts about how to resolve this, but I am curious: what the readers of this blog think would be appropriate and fair?

Here is my version of the simulation in clojure. Things to note:

* The simulation runs until each of the four couples has one male.

* Only one random source is used, as apposed to one for each couple.

* RNG is a mersenne twister using the colt library.

* The initial couples are included in the population count.

* The 3000 results are averaged using rational mathematics.

Source:

https://gist.github.com/757728

Results:

landsburgs-sim.core=> (float (simulate-times 3000))

0.48628482

landsburgs-sim.core=> (float (simulate-times 3000))

0.48481178

landsburgs-sim.core=> (float (simulate-times 3000))

0.48656064

landsburgs-sim.core=> (float (simulate-times 3000))

0.48352513

Steve, I’m sorry but you’re going to lose this bet. You yourself acknowledge there would be the same number of females and males. That ratio in the entire population would by definition by 1:1.

I think you’re conflating the overall ratio and the weighted average ratio for all the families.

You yourself explained why these are not the same thing, but for some reason conclude the average ratio is somehow truer than the overall ratio.

I’ve simulated several thousand families procreating on my own rough spreadsheet, with the stop rule you specified, and I keep getting the same thing: a ratio of 1:1.

Oh, I almost forgot, the mersenne twister gives an number between 0 and 1. This is rounded to integers using alternating rounding. The first 0.5 gets rounded up, the second down, the third, up, and so on.

@ Larry:

I think the “Las Vegas” fair would be about 46.67% and if my simulation is correct certainly not 46.66%.

The question asks: What fraction of the POPULATION is female?

There are couples. There are children.

Couples + Children make up the population

This is simply an unambiguous fact. There can be no argument as to who is in the population. Only someone who is so adamantly opposed to admitting they are wrong could even attempt to argue that the couples should be left out of the population.

Steve said: “I’ve specified several times in this thread that if people want to change the setup (by changing the number of families or making other tweaks to the assumptions),”

Steve, there’s only one person that insists on changing the setup. Right now, he’s down $500.

If you want to ensure victory, maybe you can make the assumption that only 45% of children will be born female. After all, it’s not specifically stated in the problem, and it does support your answer. That’s what this is all about, right? Changing the parameters to support your flawed reasoning? Seriously, this asks about a country and you want to use FOUR couples, and then ignore the couples as part of the population? Come on…

Larry > I think you should only bet if you have a genuine disagreement, instead of just confusion about the terms.

If you think that the parents should count as population, I think that Landsburg could agree to that. Then I think he would expect the answer to be somewhat higher than 44% but below 50%. If you disagree with that, then you could bet about that.

Is what I think would be fair.

@ErikR Yes, the question initially asks for the fraction of the population that are girls, i.e. F = G/(B+G). As Steve immediately noted, that question is impossible to answer without more information due to low, but strictly positive, probability events such as the last 100,000 families in a row having boys on the first try. So, we can only answer the question in expectation. That is, E[F]. You don’t get to slice up F any way you want.

Larry,

I think the chance of you losing this one is almost zero, so now you are in a bet for which both parties know the outcome with near certainty. As Steve has graciously acknowledged, you are in the driver’s seat on this one.

When you asked for the inclusion of the four mothers and four fathers, did you know it would move the expected ratio up to about 48.5%, or did you think it would move all the way up to 50%? I’m just curious.

I think the resolution of this is between you and Steve. I don’t see an obvious way to go, so I’ll respect your call on it.

Further explanation. My answer is based on betting on each country individually.

Realistically in this run there will probably only be at max 25 possible fractions for each country. The median country will be 8 boys and 7 girls or 46.67%

The reason this seems more realistic is because neither of you risk the entire $ 500. Unless it was the stock market, My wife would kill me if I bet $ 500 even on an 75% proposition.

Of course you would want to put the advantage in your favor. I.e. Steve pays you $ (500/3000) for every country that has a fraction > 46.67.

“Yes, the question initially asks for the fraction of the population that are girls, i.e. F = G/(B+G). As Steve immediately noted, that question is impossible to answer without more information due to low, but strictly positive, probability events such as the last 100,000 families in a row having boys on the first try”

No, it’s quite possible to answer assuming an infinite number of families (which is a perfectly fair reading of the initial question).

1/2 of the families have 1 boy.

1/4 of the families have 1 boy out of 2 children total.

1/8 of the families have 1 boy out of 3 children total.

etc.

The proportion of boys is ( 1/2 + 1/4 + 1/8 + …) / (1/2 * 1 + 1/4 * 2 + 1/8 * 3 + …) = 1/2.

Steve:

I don’t know if you can correct my previous post, I should have ended it with:

”

Of course you would want to put the advantage in your favor. I.e. Steve pays you $ (500/3000) for every country that has a fraction <= 46.67.

"

@ErikR:

No, you are confused. The population is what’s on the ground. That’s g/(g+b). If I have 20 people and 17 are girls that’s 85% girls. For any possible future there is a population, and that is the denominator. The population is what’s on the ground, and we are interested in what fraction of that is girls. So g/(g+b) Your E(g) + E(b) corresponds to nothing on the ground, to no real set of humans. It’s just the wrong number.

As for including parents — that can only bring the ratio closer to 50%. It cannot make the ratio equal to 50% in any case unless it starts out at 50% in that case. Is that not obvious? Since mother and fathers are equal?

No, you are as wrong as Steve is. The original google interview question does not specify the expected value of the ratio. That would be silly. Any reasonable person can see that the original question was asking for

E(G) / E(G+B)

No one interested in girls born in a country would care about the expected value of the ratio.

Even the boxed question presented here, with Steve’s addition of the word “expectation”, does not explicitly specify expected value of the ratio. If it did, then there would be little controversy. Although it would be an absurd rephrasing of the google interview question, to which the answer is plainly exactly 1/2.

Google Part Two

Interviewer: Assume you are President of a country that recently lost its water supply. The entire population will die of dehydration by the end of the day unless you are able to supply the entire population with water. How do you save the people?

Economist: Well, first I would start by assuming the entire population is 4 people. Secondly, since two are adults, I will exclude them. Next I give each child a bottle of water. Crisis averted for the low cost of 22 cents. I will bet anyone that my answer is the right one.

Did I get the job?

@ ErikR Deeming the question unreasonable does not not change what it is asking. I wish it did… my quals would have been a breeze.

I have looked at the simulations and agree that 4 families does produce the ~44% number. However, you’re not counting the parents, which drive that number above 46.5%, and the original question asks “What fraction of the population is female?”. Surely, the mothers and fathers must be counted. I will take the bet, assuming we are looking at the population, and not just the children.

@RJB:

The problem is not that the google interview question is unreasonable. The google interview question is fine. The answer is clearly exactly 1/2.

What is unreasonable is to interpret the question as asking for the expected value of the ratio. Since the question is ambiguous, reasonable people interpret it in a way that makes the most sense. No reasonable person cares about the expected value of the ratio in the context given, so the most reasonable answer is to compute

E(G) / E(G + B)

Erik:

Here is what appears to be the original Google question is stated at various places on the web:

–

In a country in which people only want boys, every family continues to have children until they have a boy. If they have a girl, they have another child. If they have a boy, they stop. What is the proportion of boys to girls in the country?

–

Talk about an absurd question. By ‘proportion’ I assume they mean ‘ratio’, but the ratio is random and could be any number from 0 to infinity.

So you could modify the question in a number of ways:

1. What is the ratio of the expected number of boys to the expected number of girls?

2. What is the expected ratio of boys to girls?

3. What is the ratio of the expected number of girls to the expected number of children?

4. What is the expected ratio of girls to children?

5. Do you expect this country to have more boys or more girls?

All of these except 2. are fine. You prefer 1. and 3. Professor Landsburg chose to discuss 4. The people at Google probably intended for the question to be more like 5.

I’m scratching my head, though, to try and understand why so many people are unwilling to accept 4. as a legitimate way to pose this question. And I don’t understand why so many people aren’t taking advantage of this opportunity to learn that the answer to question 4 is different from the answer to question 3.

1) It is Prof Landsburg’s blog; commenters are guests.

2) Yet, is there anyone else semi-disappointed by the tone?

(e.g “too stupid to think about this problem”, “seems unable to follow the mathematics” in response to “what you’re doing is borderline cheating”)

@ William:

I think it shows that he enjoys teaching. Right now he seems like a patient parent trying to help an angry child with homework. It’s possible that he is willing to take abuse if it will help others to learn.

Or maybe he just likes letting people show their true colors.

@ ErikR:

Yes there are many different ways to interpret the original question. 2 approaches seem reasonable to me:

1) You can explain your interpretation of the question defend your answer as it relates to your interpretation.

2) You can challenge others on whether their answer is consistent with their interpretation.

E.g. Your interpretation is that this puzzle is ambiguous. Ok. Given. You then say “the most reasonable answer is to …”

This answer doesn’t seem to match your interpretation. I.e. how can their be a most reasonable answer to an ambiguous question?

An answer that would match your interpretation would be something like:

“It is unfair for ask ambiguous questions in an interview and expect 1 answer. Being unfair is evil. Google does no evil. Therefore, this is a trick question. Google never asks this question”

It is not difficult to understand. In the real world, when people are faced with a question, it is generally a good idea to try to understand how the answer to the question will be used. In this case, it is difficult to conceive of a case where the expected value of the ratio will be useful to someone, while the ratio of the expected values would not be useful. Therefore, it makes no sense to choose the interpretation that is more complicated but no more useful.

Thomas Bayes,

I think most of us are willing to accept 4 as an interesting puzzle, but just not for countries. Families for sure, or maybe even small collections of families, such as blocks as in Steve’s example. But it is common knowledge that countries are LARGE collections of families, and the distinction between 3 and 4 vanishes to some distant and irrelevant decimal place. Even for the smallest country, Tuvalu (I didn’t count the Vatican because they do not reproduce there) which has about 3000 families, the answer to 4 would be .49992. Perhaps a genius could see right away that the distinction between 3 and 4 is irrelevant when the population is country sized. Anyway, thanks to Steve, I know that now.

Artist Dan: I will take the bet including the parents, provided I get to revise my prediction for the expected ratio. My revised prediction will still be less than 50%.

Quite simply, by using reason to choose among possible interpretations of the ambiguous question. One uses one’s experience and knowledge to determine what makes the most sense in the context of the question. I already explained this in prior comments.

ErikR:

No, the question concerns the fraction of the population that is female. Then Steve adds that he is asking for expectation. SinceE(G) / E(G+B)

involves fraction of the population, and expectation, it is a perfectly reasonable translation of the problem from English to mathematics.So suppose I ask you to add 3 + 4 and then square the result. Your answer is 25, because 3^2 + 4^2 = 25. I say no, that’s not what the question asked. It asked you to *first* add 3 and 4, *then* square the result. You say “The expression 3^2 + 4^2 involves 3, involves 4, and involves squaring. Therefore it is a perfectly reasonable translation of the problem from English to mathematics.”

Can you see why I might not be convinced by that argument?

Will A,

I think you’ve misunderstood William’s post. He is quoting Steve on at least some of those.

Steve,

Poor comparison, but typical of someone who is more concerned with pure mathematics than with how reasonable people might apply mathematics in the real world.

ErikB

This is from Steve’s original post:

“… in expectation, what fraction of the population is female?”

The expectation of girls as a fraction of the population CLEARLY means E(G/(B+G)), NOT EG/E(G+B).

Regards,

Ken

By the way, why do so few people use the blockquote … /blockquote HTML tags (with the less-than/greater-than brackets) when quoting someone in the comments here?

Thanks for illuminating this interesting statistics oddity!

I’ll take your bet that five randomly chosen statistics professors (from your choice of the ‘top ten’ institutions) would select my description of the problem (basically any description which would result in 50/50) as more appropriate. Provided they have only the original question (and your stipulation that this is ‘in expectation’), I’m certain a majority of would agree that the your proposed simulation isn’t an appropriate description of the original question.

How about 1,000?

@ Neil and Thomas:

Is it possible to think about a country as a group of people and gender being an attribute that different people would have based on some random factor?

Is it possible that some advertisers would be interested in small groups of people. E.g. Communist NRA members who might buy an electric car?

Is it possible that an advertising company would be interested in expected ratios as it relates to groups of people and attributes that they have?

To me the answer to these questions seems to be yes.

Lubos et al.,

Obviously Steve got his original problem statement wrong by any sensible definition of a ‘country.’ But under certain unrealistic assumptions he does have a correction to the 50% number.

The new problem statement is designed to incorporate two important unrealistic assumptions. With ‘countries’ defined as four families, and with the reproductive process in each country always ending permanently with a boy, this becomes a sucker bet.

The way the new problem is defined, the sequence of births

BGGBGBGGGGB

must always terminate in a B (30 years is enough to do that for practical purposes).

The new assumptions are very far from the original problem statement; obviously there are no ‘countries’ remotely resembling these two bizarre conditions. But under these conditions Steve’s going to win.

Ken:

You are wrong. The most reasonable interpretation of the question, in the context, is

E(G) / E(G+B)

ErikR >

Could you try and explain why you think intuitively that your interpretation applies better to the real world? It seems like a very weird way to view the question to me, almost like the square-sum example.

Jim Davis: It appears we have a bet.

(I apologize for posting this on two threads. I believe this is important enough to make sure both discussions have a chance to see it. I hope you agree.)

Okay people, let’s construct a betting game that is based on the underlying point of this problem. Here’s how it works . . .

You toss a fair coin using one of two strategies:

A. You toss until you see heads, then stop.

B. You toss until you see tails, then stop.

Under either strategy, you record the number of heads and the number of tails. Using the same strategy for each trial, you do this 10,000 times (or, better yet, a larger number of times). Of course I’ll let you use a trusted random number generator to do this. After the 10,000 trials, you tell me the ratio of heads to tails. I’ll then guess your strategy. If I’m correct, you owe me $1. If I’m wrong, I owe you $1.

After playing this game once, you can pick a different strategy and we’ll play again. We’ll do this several million times with you selecting a possibly different strategy each time, and then we’ll square our debts when we are finished.

We can play this game millions of times because you could describe a method for changing your strategy with each new game, and I could describe a method for guessing. A trusted random number generator could ‘toss’ the coins, and a trusted third party could run the program.

What is the point? The point is I will win money in this game. I will win because the expected ratio is not 1/2, and because it is more likely to see more heads than tails with strategy A, and more tails than heads with strategy B. Sure, the expected number of heads is equal to the expected number of tails for both strategies. But if you think that is all that matters, then you will lose money on this game. I will win because there is a statistical difference in the data that are produced by the two strategies.

To bring this back to the original puzzle. There will be a statistical difference in the populations for a country that uses the ‘everyone has a boy’ policy vs one that uses the ‘everyone has a girl’ policy vs one that uses the ‘everyone has two children’ policy. On the surface the populations will look the same: the expected number of boys will equal the expected number of girls. But if you don’t understand or believe they are different, then I would take all of your money in the game I described here. And for those of you who think “it doesn’t matter because the population size will be large”, then let’s have each play of the game use 1 million or even 10 million tosses. I would take your money even faster.

Tom:

The new problem statement is designed to incorporate two important unrealistic assumptions. With ‘countries’ defined as four families, and with the reproductive process in each country always ending permanently with a boy, this becomes a sucker bet.Fine. You tell me how many families you want, and you tell me what how long you want to run the simulation (so it doesn’t always terminate with a boy). I’ll give you my new prediction, which will still be under 50%.

That kills both of the assumptions you object to. Are you now willing to take the bet?

Ehm, isn’t the whole point that all families always terminate with a boy? I don’t understand that objection.

Steve,

Interesting! You don’t realize that the only effect of the stop-with-a-boy rule is to exclude national birth sequences that terminate with a girl? (I hesitate to even type that tautology out, but if you’ve kept your thinking entirely inside your sequence of series, it’s possible that you don’t see it yet.)

That might be interesting after all. I’ll get back to you.

In any bet there’d have to be an independent arbiter.

@ Thomas Bayes:

Flat out brilliant.

However I’m starting to agree with the other side here. I’m a computer programmer who writes code using the less than sign.

E.g.

if (x < 50) { BeginMeltDown(); }

I now know that there is no difference between < and <= so from now on, I'll write code like:

if (x <= 50) { BeginMeltDown(); }

After all they both mean the same thing. And even if they don't the difference is trivial.

Thomas Bayes:

Very nice! I would only gamble with you in that game if I got to be the strategy guesser!

If only Steve had led with something like that.

@ ErikR: “You are wrong. The most reasonable interpretation…”

Perhaps you should be a little less ambitious with telling people they are wrong if you just think you differ in interpretation.

Will A –

You make an excellent point. For the ‘everyone has a boy’ country, there is a 50% chance that the number of girls is greater than or equal to the number of boys, and there is a 50% chance that the number of boys is greater than the number of girls. You’re correct: many people evidently think that the ‘or equal’ part is trivial.

@ ErikR:

Your complaint wasn’t about the solution, it was about the interpretation. I would think that whether or not you accept Thomas Bayes’s obviously brilliant explanation of the solution, should have no bearing on this.

I’m not asking this rhetorically, but I’m interested to know if you have removed your objection to using Steve’s interpretation. If so, what was it in the explanation that changed your mind?

Your problem description is under-specified.

The fraction of the population that is female will vary from simulation to simulation. So you do not get a single number, you get a distribution.

You have not specified how to turn such a distribution into the single number you are asking for. Do we use the mean fraction of girls, the median, the mode? Do we use the fraction of girls across all the samples?

Respecify the problem with sufficient precision and stop wasting everyone’s time.

The actual answer to your question is: the fraction will vary from one population to another. If you want some statistical summary, ask for it.

1. Specifically if you ask “what is the expected value for the fraction of girls in the population in the first generation?”, this depends on the number of families. For one family the fraction is 0.3-ish. For 50 it is close enough to 0.5.

2. If you ask “what is the likelihood of a given child being a girl?”, it is 0.5.

3. If you ask what is the expected value of an estimate for the fraction of girls, based on a small sample, this is the same as (1).

So, you are just playing a stupid word game. Similar issues arise with the three-door problem, which is also under-specified.

Will A:

You seem to be reading something between the lines that is not there. Steve’s interpretation of the google interview question is absurd.

Thomas Bayes posted a nice example where the expected value of the ratio is important in the context given.

Steve,

I’m happy to find you so flexible! Yes, I would need to eliminate the “terminal boy” in the birth sequence.

The simplest way to eliminate the “terminal boy” factor is to order the births of all the children in the country each year. Each year we (they) may have lots of kids, but we throw them into time order arbitrarily. Then all the births are in time order.

Then in every country we toss out the very last birth. Boy or girl, either way. That way there’s no question of a “terminal boy.” We get births over time, each one random, but we just don’t include the very last birth in the ratio. This modification only affects one family per country. We can use larger countries if you feel that throwing out one birth makes too much difference. [;-)]

Are you game? Under those conditions, how much under 1/2 should we converge to?

(You do see where “a hair under 0.44″ comes from? The country size is about 8, and you have about an extra half boy per country because you always terminate with a boy … and half of 1/8 is 0.0625 …?)

Innocent Bystander:

You have not specified how to turn such a distribution into the single number you are asking forOn the contrary, the question specifically asks for an expected value, which, by definition, is the mean of the distribution.

Tom: Can I get a clarification on what it means to “throw out the very last birth”?

In particular — if the very last birth is a boy born to family X, does family X stop reproducing (because they’ve had a boy)? Or do they continue reproducing (because that boy was thrown out)?

Also: Are we throwing out the very last birth each year? Or just the very last birth in the very last year? Or … ?

To clarify, we throw out exactly one birth per country (the final one) over the whole time of the simulation, until it terminates.

Steve,

They still stop reproducing. The populations are generated exactly the same as before, except we don’t count the last child in the Ng(Ng+Nb) ratio of the country.

Ugh, Ng/(Ng+Nb) ratio not product

Tom: And does the simulation run for a fixed number of years? Or does it continue until every family is completed?

More precisely: Are you computing E(G/(G+B-1))? Or something else?

Steve,

Either way. We could run until completion; we could run it for one year and throw out the last child that year. Whatever you like.

We generate N children total, then we calculate for the first N-1 children.

Ugh, my formula seems to have been interpreted as an html tag. Last sentence should read:

We generate

Nchildren total, then we calculateE(G/(G+B))for the firstN-1 children.“You are wrong. The most reasonable interpretation of the question, in the context, is

E(G) / E(G+B)”

-ErikR

Wow… I had no idea that actually understanding that the expectation of the ratio is in fact E(G/(B+B)) is NOT reasonable. I’m glad there are people like you who don’t understand what expectation means, but is here to let everyone know what is and is not reasonable.

I guess in my graduate probability courses, when my professors wanted me to compute the expectation of a ratio I should have known that they unreasonably wanted me to compute E(X/Y) instead of the much more reasonable EX/EY.

What I understand very well though is your refusal to admit that you were wrong, so have to make the point that even though you might have technically been wrong, you were reasonably right. There’s no shame in being wrong. But there is shame in adamantly refusing you didn’t understand the problem, then claiming that it is unreasonable to solve the problem as it is stated, but should be solved as you misunderstood it.

Regards,

Ken

This was a fun problem. I wrote a more complicated program than the ones here. For four families, the results can vary pretty radically and have to be averaged across a large number of runs. For larger data sets, I found that percentFemale hovers around 44 percent. Sounds like a bunch of frustrated men in this country…

The parameters that are used as input for my program are:

StartingNumCouples (varied wildly between runs)

MonthsOfDuration (varied wildly between runs)

AgeOfMarriageInMonths (usually ran with 240)

MaxMarriageAgeDifferentialInMonths (usually ran with 48)

AgeOfDeathInMonths (usually ran with 960)

AgeOfInfertilityInMonths (usually ran with 720)

OddsOfMaleOffspring (always ran with 0.5)

MonthlyMarriedFertilityRate (always ran with 0.1)

CHEERS

Ken:

You need to get your nose out of your probability texts and start interacting with the real world. You might learn to be useful!

A person on the other thread pointed out that I was incorrect to say that I will win faster with a larger number of tosses in each round of the game that I described. They are correct. I’m not sure what I had in mind at the time, but the probability of me winning each round of the game will be something like 1/2 + .14/sqrt(K), so I’ll win more often with smaller values of K. Sorry for the error, and thanks to the poster for the correction.

The point of the game is still valid. You have a better than 50% chance of telling the difference between a country that has a policy of ‘everyone has one boy’ and a country that has a policy of ‘everyone has one girl’. They are different.

@ ErikR Most of us frequent this blog because Steve has a history of being provocative and insightful. We enjoy this as it it makes us think hard and reconsider our preconceptions. Moreover, I find the comments section (usually) filled with insightful commenters that continue to prod the intellectual exploration that Steve initiates. You seem to be here to be smug and condescending. You have been quite successful. Thanks to all who have taken an interest in actually understanding this problem and its possible interpretation/solution. It has been fantastically entertaining reading.

@David McFadzean The code you posted, https://gist.github.com/757093 has a couple of issues. First, the numbers do not match those pointed out in the question; second you are only running a single simulation, rather than an average over many (e.g. 3000), third, if nCouples = 1000000, then nFemales and nMales should both equal 1000000 as well, not nCouples/2, as there are two people in each couple. However 3 is irrelevant anyway, as we are interested in the children, not the existing adults. After editing your script to take these issues into account, the result of which is here,

https://gist.github.com/758222

Running this script with the stated values (nCouples=4, iters=3000), results in,

$ landsburgsmoneyredux.py 4 3000

0.43591269426

increasing the number of iterations,

$ landsburgsmoneyredux.py 4 30000

0.440252173823

increasing the number of families,

$ landsburgsmoneyredux.py 7 3000

0.46405814291

Etc., etc. Making a quick plot of the percentages where nCouples varies from 2~15, and iters is held steady at 10000, yields the following graph,

http://i.imgur.com/OfBOR.png

In any case, hopefully these two bits of info make it abundantly clear that nobody should be taking his bet, and no one is going to win Landsburg’s money.

Whoops, I said 2~15 for the graph, but I upped it after writing that in – should be 2~20 at 10000 iterations each.

ErikR,

One of the most useful things I’ve learned is how to read and understand the English language. “Compute the expectation of a ratio” means compute the expectation of a ratio, not compute the ratio of expectation. It’s one of the most plain and clear sentences I can write. I’ll write it again:

Compute the expectation of a ratio. Is this sentence confusing?

Thanks for worrying about my usefulness and my interactions in the real world (a world losers say exists when they know they are completely wrong). I’m pretty sure my usefulness in the world is secured, particularly because I understand basic sentence structure.

Here’s a little quiz: Does the expectation of a ratio mean the same thing as the ratio of the expectations? Do you understand that both have “real world” applications? Do you understand that these two things are actually different? Do you understand that understanding the difference is useful?

Regards,

Ken

Ken,

If the google interview question, or even Steve’s rephrasing of the question, had said “compute the expectation of the ratio”, then there would be little controversy.

Hi Steve, I’m one of the (probably many) commenters coming from Marginal Revolution to this conversation.

I too, think you have misunderstood the problem. Specifically I think the answer you’ve outlined is the average fraction of girls in each family, rather the the population as a whole.

You told Tom:

“Fine. You tell me how many families you want…I’ll give you my new prediction, which will still be under 50%.”

If you tell me what your prediction would be using your original scenario, but change it to 1000 families per simulation run, and what my winning level would have to be I will bet against you if your prediction is non-trivially different from 50%.

Best,

Dan

Immediate follow-up. After re-reading your post I don’t expect there to be room for a bet between us.

I believe most of the argument here is a result of the specific examples you’ve chosen to illuminate your point. The examples you’ve completed the math on (1 or 4 familes), show marked differences from 50-50 splits. Your actual argument is much more mundane, as “k” gets large your predicted value approaches 50%, and the limit as “k” reaches infinity is 50%.

My guess is that people won’t get too exercised over your prediction that a population of 1000 families will “only” have 49.975% girls.

Here is another simulation (note: I have not read all the comments, but I read the earlier comments and saw people posting their simulation code and results). I used the same family sizes that Jonatan used in his graph, ran each simulation until every family had a boy (as opposed to a fixed number of years), and ran each experiment 3000 times.

The code should run under any Common Lisp implementation. Here is my output from the output-results function. My results lead me to refrain from taking the bet (I have not reasoned through the math yet, but wanted to check if the bet was worthwhile). All the code is pasted below the output.

CL-USER> (output-results)

fams avg-girl-frac

1 0.3061279

2 0.3836482

3 0.4258145

4 0.4424949

5 0.449346

10 0.4775635

100 0.49688935

1000 0.49971402

10000 0.49997494

;; Begin code

(defun frac-fem (fams)

“Runs the simulation, returning the fraction of females.”

(let ((girls 0))

(dotimes (i fams (/ girls (+ fams girls)))

(loop until (zerop (random 2)) do

(incf girls)))))

(defun rep-frac-fem (fams &optional (sims 3000))

“Repeats frac-fem and takes the average.”

(/ (loop repeat sims summing (frac-fem fams)) sims))

(defun output-results ()

“Run simulation and format results to a table”

(format t “fams avg-girl-frac~%”)

(loop for fams in ‘(1 2 3 4 5 10 100 1000 10000) do

(format t “~8a~f~%” fams (rep-frac-fem fams))))

Steve,

Where did you state that this certain country is one where nobody dies? You need that assumption for the population (number of people living at a point in time) to be equal to the number of people born.

You assume away mortality. Is it excusable to do that and not say so?

The code in my prior post lost some of its indentation, so the following updated code replaces some of the spaces with underscores. Additionally, all occurrences of “frac-fems” in my code have been replaced with “frac-girls,” and the documentation was updated, both changes made to indicate that the simulation calculates the fraction of newborns that are girls, as opposed to the fraction of newborns and parents that are female. While that wouldn’t bring the expected value to 50%, it would bring it high enough that a bet is worthwhile at the 46.5% threshold (the problem in the blue box says “what fraction of the population is female?” but the directions below the box say “then compute the fraction of girls in the population” which I interpreted as the fraction of newborns that are girls).

CL-USER> (output-results)

fams____avg-girl-frac

1_______0.3061279

2_______0.3836482

3_______0.4258145

4_______0.4424949

5_______0.449346

10______0.4775635

100_____0.49688935

1000____0.49971402

10000___0.49997494

;; Begin code

(defun frac-girls (fams)

__”Runs the simulation, returning the fraction of newborns that are girls”

__(let ((girls 0))

____(dotimes (i fams (/ girls (+ fams girls)))

______(loop until (zerop (random 2)) do

__________(incf girls)))))

(defun rep-frac-girls (fams &optional (sims 3000))

__”Repeats frac-girls and takes the average.”

__(/ (loop repeat sims summing (frac-girls fams)) sims))

(defun output-results ()

__”Run simulation and format results to a table”

__(format t “fams avg-girl-frac~%”)

__(loop for fams in ‘(1 2 3 4 5 10 100 1000 10000) do

______(format t “~8a~f~%” fams (rep-frac-girls fams))))

rkillings:

“Where did you state that this certain country is one where nobody dies? You need that assumption for the population (number of people living at a point in time) to be equal to the number of people born.

You assume away mortality. Is it excusable to do that and not say so?”

You are fighting the hypothetical. If you considered mortality rate, you should also consider the difference in ratio between male and female births etc etc. It was stated in the first post that

“And no, it’s not wrong because of small discrepancies between the number of male and female births, or because of anything else that’s extraneous to the spirit of the problem.”

Dan:

“I too, think you have misunderstood the problem. Specifically I think the answer you’ve outlined is the average fraction of girls in each family, rather the the population as a whole.”

No. He looks at the population as a whole.

Dan:

“I believe most of the argument here is a result of the specific examples you’ve chosen to illuminate your point. The examples you’ve completed the math on (1 or 4 familes), show marked differences from 50-50 splits. Your actual argument is much more mundane, as “k” gets large your predicted value approaches 50%, and the limit as “k” reaches infinity is 50%.”

Steven Landsburg adressed this in an earlier post:

Steven Landsburg:

“As for the result approaching 50% as the number of families gets large:

a) Yes, I pointed this out in the original post.

b) The fact that the result happens to approach 50% does not imply that the “official” argument has any validity. Just because an argument reaches an (approximately) correct conclusion does not mean it’s a valid argument.”

Tom:

1) So then if I take E(G/(G+B-1)] for a completed population, is that what you’re asking for?

2) If so, and if my quick calculations are right, this seems to be well approximated by (1/2) – (1/(4 – 4k)).

3) In particular, for k=1, the expected fraction of girls is now infinite.

Edit:The calculation in 2) is definitely wrong.@171 Dan K:

“My guess is that people won’t get too exercised over your prediction

that a population of 1000 families will “only” have 49.975% girls.”

(%include standard mathematician/physicist/engineer jokes)

I’d modify your statement to say “…

mostpeople won’t get too …”A mathematician will note that the answer is not simply 50%.

An engineer will note that, for any reasonable population size, the

result, for all practical purposes, is 50%.

Ron:

But even the engineer might care that the almost-exactly-correct answer of 1/2 was reached through a thoroughly bogus argument, because he’ll want to know whether or not he can trust such arguments in the future.

Let’s talk about real life for a minute.

There is substantial evidence that certain couples are more likely to have boys than girls and vice versa.

I am 1 of 4 brothers, no girls, and I have 13 male cousins and 2 female cousins. A small sample doesn’t prove anything.

However, if my family played by your rules then there would be 4 boys and no girls instead of 17 and 2. If the sexes were reversed then I would be part of a bigger family with more cousins.

Unfortunately, I am too stupid to understand how flipping a fair coin can be anything but 50-50. Or maybe I am too stupid to understand why the sex of a child is different than a coin flip.

Neil Wilson:

Flipping a fair coin can only be 50-50 (by definition), and the sex of a child (in this idealized problem) is exactly like a coin flip.

Also, most engineers will retain terms that involve 1/K when they calculate a mean or variance.

I would be happy to take your bet for the full amount of $5000.

This is a definition argument you are trying to win, as it appears you have conceded that, indeed, E(G)/E(G+B) is indeed .5 ‘in the limit’. In other words, if every birth in the country is recorded in two columns, G and B, and we keep a running talley, the statistic G/(G+B) will converge to .5. Trust me, we can be more fancy with technical mathematical terms about convergence, or we can point to the empirical simulation results to confirm this. This gets to point of the original solution that the stopping rules of the individual families will not affect the observed fraction of live births that are boys or girls. Imagine these records recorded on a ticker tape, where at any point on the ticker tape, we can report the running fraction of girls.

G B B G B B G G G G B B G G B B B B B B G G

Ultimately, family stopping rules just draw the lines of separation in difference places, which effect what children experience what kind of family but they don’t effect the ultimate distribution of the population.

However, as you point out, this global family policy will have a profound effect on how actual families within this country look. For example, no family in this country will have 2 boys.

And, it is true that, taking the unit of observation as a family that has completed child rearing, we get the counter-intuitive result that the mean fraction of boys PER FAMILY is 1-ln(2) or approximately .306. In other words, in that same hospital, if we make marks on the ticker tape to separate the families, and then record the fraction of girls in each family, and then take a sample mean on the fraction of girls in each family, the limit will approach 1-ln(2)

B 0

G B .5

B 0

G G G B .75

G G G G B .8

…

Then you seem to assert that this is what you clearly meant by expectation, although there is some confusion about mapping this interpretation for a single family to what is meant by a country. Clearly, the precise terms and problem formulation are very important, and both mathematicians and engineers would cringe at the problem statement as given.

Part of the problem in the problem statement is the well-known challenge of calculating the expectation of a ratio rather than the ratio of expectations. Or, as you put it, the difference between E(G/(G+B)) and E(G)/E(G+B). There are papers about this issue, but I don’t think you want the bet to be about this, do you?

However, consider this interpretation of expectation that seems more compelling. Now, I assert the simplest computation above that simply gives equal weight to every birth in the country is the most sensible interpretation for computing the ‘expected’ fraction of girls in the population.

However, to provide some contrast, consider this interpretation.

As noted earlier, each child will experience a different family experience based on family size, which is the key idea of your counter-intuitive result. However, you are leaving out the fact that, if the family is larger, more people will have that experience. Hence, the interpretation of ‘expectation’ should give larger families a higher weight.

So, let’s consider the scheme from earlier, but now let’s weight each fraction by the number of children that will experience it.

B has 0 fraction girls, and 1 child experiencing it.

GB has .5 fraction girls, 2 children experiencing it.

GGB has 1/3 fraction girls and 3 children experiencing it. etc. Recomputing the expectation in this way gives us .5 (I can send you the steps), as we found previously in our simple scheme of recording births at the hospital. Should the experience of an only child have twice as much weight as a child born with one sibling? Why? Were you an only child, Steve? (Just teasing…)

Do you really intend for the bet to come down to your definition of expectation? The cleanest way to make your point is to get out of the business of talking about countries and focus on the experience of a single family… there you have a interesting point. In that case, the family stopping rule will affect the ‘average’ experience of a ‘family’. But, the country will not suddenly have more boys or girls born in their hospitals, and I think that is the key metric for describing the composition of the country.

There is an easier way to tell a boy-stopping rule country from a girl-stopping rule country. Just look around. If you see a lot of one boy families it is the former and if you see a lot of one girl families it is the latter.

“If the google interview question, or even Steve’s rephrasing of the question, had said “compute the expectation of the ratio”, then there would be little controversy.”

Seriously, dude, Steven wrote:

“… in expectation, what fraction of the population is female?”

I mentioned this in a previous comment think that as you said “there would be little controversy”, yet you persist on being wrong and here’s why. Steven’s sentence literally means “what is the expectation of the FRACTION of the population is female”? Again, I’m relying on my super useful skill of reading English and deduce that fraction means ratio. Thus my restatement “compute the expectation of the ratio”. Did using the word ratio, instead of fraction, confuse you? Do you not understand they are synonyms?

Of course, to hold on to what you think is some dignity you will deny everything I’ve said in this comment because instead of looking for the truth of the situation, you’re looking to win an argument that you’ve all ready lost, but cannot admit it.

You want to see how easy it is to admit you’re wrong? I was the second commenter on the original post “Are You Smarter Than Google?”. Take a look. I was wrong because I originally misread/misunderstood the post the same as you and computed the ratio of the expectations, instead of the expectation of the ratio.

Even with the PROOF that Steven was asking you to compute the expectation of the ratio of girls with respect to the population, I think you’ll still deny that’s not the “reasonable” way to interpret the sentence above. However, it’s only unreasonable because you misread or misunderstand it. Since YOU misread/misunderstand it, and since you are the arbiter of what is and is not reasonable, it MUST be unreasonable, right?

Plus, I’m being a smart ass in all my replies to you and it would just kill you to admit that I’m right. The need for self-deception in the face of being wrong, especially in front of someone who is taunting you, is huge isn’t it?

Regards,

Ken

Paul Hyden: Per the terms of the bet, we will leave any dispute over interpretations to a panel of statistics professors.

I accept your $5000 challenge and will be in touch by email about the details.

Steve,

1) Two answers. Logically, no, it’s not. I am asking for E(G/(G+B)) for the first N-1 births.

Practically speaking, as a guide to making sure we’re talking about the same algebra? Yes, for completed countries, of course you happen to get the same answer that way. Because in completed countries, the way you laid out the rules in this post, your last birth is always a boy. So when I average over the first N-1 children, I always get one fewer person but zero fewer girls.

But completed countries are of course just one case out of many. Except as an algebra check, we’re not too interested in a curiosity that applies only to completed countries.

It’s approximated. We can talk later about how well approximated it is.

It’s undefined. I can’t say infinite. Half the single-family countries now have no children at all (that we measure). Can’t get a ratio for them.

In 3), if we limit ourselves to countries that have any children at all, the exact ratio is 1. Right? If we only count the first N-1 in a

familywe never get a boy at all.I’m only interested in countries that have at least 2 families. I have to draw the line somewhere!

Tom:

if we limit ourselves to countries that have any children at all, the exact ratio is 1. Right?Perhaps this is true, though I don’t immediately see why. I’m not sure whether this is because I don’t understand what you’re asserting or whether it’s because you’ve got an argument in mind that I haven’t twigged to.

@joe Thank you for the first correction, the initial number of males and females is indeed the same as the number of couples, mea culpa.

I’ll accept averaging the result over 30,000 iterations. That isn’t in the original problem statement, but I don’t think it makes a difference.

I reject your third change. Nothing in the original problem states that we are interested in the fraction of children only. It explicitly asks for the fraction of females in the population which should include the parents. I changed your code to include the parents >> https://gist.github.com/758882

Steve is going to lose the bet and here’s why: The rule the parents use to decide whether to have a baby does not affect the sex of the child in any way. The parents could try until they have a baby on a Monday, or a left-handed baby, or they could try until the parent’s ages add up to a sum greater than 50. Every year the same number of boys and girls will be added to the population keeping the ratio of females to 50%.

To be explicit, the only kind rule that could change the sex ratio of the country is one that kills the child *after* the sex is known.

David McFadzean:

Steve is going to lose the betDo you want in on this, then?

David —

Careful.

David:

There IS a gender asymmetry in this problem. The probability that the number of boys is greater than the number of girls is 1/2. The probability that the number of boys is equal to the number of girls is roughly equal to 0.28/sqrt(K), where K is the number of families. The probability that the number of girls is greater than the number of boys, then, is less than 1/2 by an amount that is roughly 0.28/sqrt(K). Steve will win, because he knows how to set his threshold based on K.

@Thomas

Steve won’t win, because when the question, as originally written (and not modified to include commentary or his interpretation) is presented to a statistics professor, it will take him a very short amount of time to come up with the answer “50% is the proportion of the population is female”.

My only concern as a bettor would be this: What is Steve doing behind the scenes to convince the professors to interpret this differently?

Steve,

To explain any further I’d really have to start posting my solution. Are you still interested in a bet on E(G/(G+B)) for the first N-1 births?

Tom:

Oh, this is clever!

For two families, with one boy thrown away —

There are n ways the two families can have exactly 1+n children, and each of these ways occurs with probability 1/2^(n+1). In each of these cases, we throw away one boy, which leaves us with a girl-fraction of (n-1)/n. So this contributes a total of (n-1)/2^(n+1) to the sum. Adding up over n, we get exactly 1/2.

I can see how this will generalize to more families.

So you are right that the original result does seem to be driven entirely by the “extra half boy”.

I find this surprising and delightful. Thank you.

Steve,

:)

Isn’t it nice? Here is the solution for the first N-1 kids in a power series form that is easy to pull apart and understand:

E(G/(G+B)) =

Sum for N = k to infinity,

(N-1 N-k)*(N-k)/(N-1)*2^-N.

I hope to heck I typed that right. Here (N-1 N-k) is N-1 choose N-k. Needs some handbook work, but the series sums to 1/2 for k>=2. But of course I didn’t solve it that way at first, by grinding on power series. (And don’t ask your computer to do 1,000,000 factorial. Mine is still steaming.)

Some folks here have talked about lessons that should be learned. A lesson I used to hear from one of my own professors, way back when, was when you get into an argument about probability, stop talking, get together, and try to write out the ensemble.

@ JustTheFacts:

The question starts “There is

a certaincountry where everybody wants to have a son.”Is the following an appropriate translation:

“Let C be the set of countries where everyone wants to have a boy. For

a certainc in the set C …” ?If this an appropriate translation, then it would seem that the following would be

anappropriate translation of the question:“Let C be the set of countries where everyone wants to have boy. For

a givenc in the set C with a population of size k …”For those just tuning in, here’s the thinking behind my point. We want to calculate E(G/(G+B)) for the first N-1 children. We let N be born and then look at the ensemble,

i.e.,all the possible birth sequences:k=1

B N=1. 1 case. Probability 1/2.

GB N=2. 1 case. Probability 1/4.

GGB N=3. 1 case. Probability 1/8.

GGGB N=4. 1 case. Probability 1/16.

GGGGB N=5. 1 case. Probability 1/32.

GGGGGB N=6. 1 case. Probability 1/64.

E(G/(G+B)) for the first N-1 is undefined (for N=1) or 1 (for N>1).

k=2

BB N=2. 1 case. Probability 1/4.

GBB N=3. 2 cases. Probability 1/8 times N-1 choose N-k = 1/4.

BGB

GGBB N=4. 3 cases. Probability 1/16 times N-1 choose N-k = 3/16.

GBGB

BGGB

GGGBB N=5. 4 cases. Probability 1/32 times N-1 choose N-k = 4/32.

GGBGB

GBGGB

BGGGB

For k=2 the series is familiar. Cancel and you get:

0/(2^2) + 1/(2^3) + 2/(2^4) + 3/(2^5) + 4/(2^6) + 5/(2^6) + … = 1/2.

For those who are thinking martingales, we’re really talking about the “stop gambling for life when you win a dollar” one.

Ugh! Very last term in the final series should read 5/(2^7) not 5/(2^6).

For anybody who tries to thread through the ensemble (the BGGGGB stuff), we’re always calculating E(G/(G+B)) for

the first N-1kids. The terminal boy is never included. Poor kid.Tom: Thanks for sharing this. I definitely learned something.

Tom,

Very interesting.

Why does it matter which boy we drop? Can’t we omit the first boy born in the nation, or any other for that matter? If we omit a boy, then the number of boys is equal to the number of families minus 1, and the number of girls is a negative binomial random variable with mean equal to the number of families. And, as you’ve demonstrated, the expected value of the ratio B/(B+G) is 1/2. Why did you suggest this? It is an interesting perturbation of the problem.

For the original problem, the most likely number of girls was equal to B-1, the probability that the number of boys was greater than the number of girls was 1/2, and the probability that the number of girls was greater than OR EQUAL to the number of boys was 1/2. And, of course, the expected value of G/(B+G) was less than 1/2.

For your problem, the most likely number of girls is equal to B, the probability that the number of boys is greater than OR EQUAL to the number of girls is 1/2, and the probability that the number of girls is greater than the number of boys is 1/2. And, for an interesting twist, the expected value of G/(B+G) is 1/2.

The controversy about the original question seems to come from two groups: i) those who deny that the expected value of the ratio B/(B+G) in the original question is less than one half; and ii) those who don’t care what the expected value of the ratio is, but believe it is silly to think about the problem that way.

Your example causes a dilemma for the first group. 1/2 cannot be the answer for both your problem and Steve’s original problem. So, for those in group i), what do you think the expected value is for Tom’s problem?

Ooops. In the second to last paragraph, it should read “i) those who deny that the expected value of the ratio G/(B+G) in the original question is less than one half;”

@Steve OK I’m in for $100

Compare:

“Steve Landsburg

December 22, 2010 at 12:07 pm

Tom:

I suspect you might just be too stupid to think about this problem.”

with:

“Steve Landsburg

December 29, 2010 at 4:54 pm

Tom: Thanks for sharing this. I definitely learned something”

Congratulations to Tom and Prof Landsburg! Persistence and an open mind, Super.

Dropping one boy from the count is a slick trick, and — OH MY — does it simplify the mathematics.

The ratio of boys to children is

R = B /(B + G),

Where B is equal to the number of families minus 1, and G is a negative binomial random variable with mean equal to the number of families which is B+1. The probability mass function for G is

Pr[G = n] = BC(n+B,n) * (1/2)^(B+1) * (1/2)^n,

where BC(n+B,n) is the binomial coefficient:

BC(n+B,n) = (n+B)! / (n! * B!).

The expected value of the proportion of boys is then:

E[R] = sum_n (B/(n+B)) * BC(n+B,n) * (1/2)^(B+1) * (1/2)^n

But

(B/(n+B)) * BC(n+B,n) = BC(n+B-1, n),

which is a wonderful simplification that doesn’t turn out so nice in the original problem. This means that

E[R] = sum_n BC(n+B-1,n) * (1/2)^(B+1) * (1/2)^n

or

E[R] = (1/2) * sum_n BC(n+B-1,n) * (1/2)^B * (1/2)^n

The thing within the sum is a negative binomial probability mass function with a mean of B, so its sum is equal to 1. The answer, then, is 1/2 without any approximations. Yippee!

Now, for those of you who believe that the answer to the original question is exactly 1/2, how do you resolve the fact that the expected value of the ratio is exactly 1/2 when you DROP one of the boys from the count? Unless I made a mistake, you simply can’t argue about this. The math is straightforward and exact for any size country.

Well, I for one never claimed it was exactly a half. I thought it was the limit as the country size is allowed to increase without bound. Statistics is full of such asymptotic estimates. If I calculate the expected variance of a variable for a small sample, I know I have to use the Bessel correction. If the sample is large (the equivalent of a large country), it doesn’t matter, not for any sigma value I am likely to use.

Thomas,

We don’t eliminate one boy per country. We eliminate the lastborn child in each country. If you run a country to termination, and they never reproduce again, then, sure, the last child will be a boy. Of course if it’s a boy your’e throwing out then it doesn’t matter which boy. Ditto girl.

I suggested the “average over the first N-1 kids” modification in order to eliminate the extra fractional boy per country produced by the stopping rule. I hoped that the exact E(G/(G+B))=1/2 result would get the group here playing directly with the BGGB bitstream instead of arguing un-illuminating stuff.

The guy who put me on the right track for this problem wouldn’t even look at my power series. He said, think of a billion pre-flipped pennies all stacked up in a tube. All you can do is take them out one at a time. I recommend that approach to everyone.

I’m not too interested in the arguments over the original problem statement. But any folks who want to understand this problem more than they want to win arguments? Go and

engagethe physicists over at Lubos’ place, say hi to them,askthem what they’re talking about, andthinksbout what they say to you. Ask the dumb questions. And, sure, hold them responsible for doing the same. But imagining that physicists can’t follow the sophomore-level math involved in this problem is … lemme say, it’s not realistic.Anybody doesn’t like the free advice, fine. I still haven’t received any apologies for the rude and absurd comments I’ve been subjected to here, so I’ve certainly got the right to give some irritating advice and throw some extra italics into the mix.

The group here has the talent to be a lot more effective than it currently is. Why not take advantage of that by networking with other experts? Life is short.

Tom. You got something better than an apology. You got Steve saying he learned something from you, and thanking you for it. I’d trade that for an apology anyday.

Thomas,

On your most recent comment. Yes. It simplifies the mathematics because they become the mathematics of fair coin flips. You don’t know how many coins get flipped, but all the flips are fair.

If we include the coin we looked at and stopped on, then all our strings include a coin that wasn’t flipped. It was glued down, heads facing up. That’s why the math is all cockeyed for that case, and that’s why you get E < 1/2.

(But exactly what this model, get a boy and then go extinct, what that has to do with arguments over the original problem statement from the previous post, I would be careful about that. )

Neil,

I don’t follow. But it sounds like your comment is probably meant kindly, which I appreciate.

Tom,

I haven’t thought about computing the statistics before each family has had its boy. I’ll think about that scenario.

A billion pre-flipped coins in a tube seems to imply that you think about each family having their children sequentially. When a coin shows ‘boy’, that family stops having children and we move on to the next family. When we stop looking at coins, we are effectively discarding the next birth, which we can associate with the last birth. It is an interesting model, but I’m not sure it is more appropriate than analyzing the situation after each family has had all of its children. But I’m not sure it is not. It is, though, a way to ensure that the expected proportion of boys (or girls) is 1/2.

You expressed some frustration in your response, so if you believe I have been rude or absurd, please accept my apology. I didn’t intend to be. I appreciate your input to this discussion, and I’m trying to learn something from everyone.

Tom’s brilliant result is obvious after it is explained. The problem posed is equivalent to flipping a fair coin N-1 times and then adding, or not, a heads (boy) to the sequence. Removing the last flip means that if the non-random coin was added, it is removed, and if the non-random coin was not added, removing the last flip doesn’t make a difference.

I guess, more precisely, that should be flipping a fair coin N-1 times, and then adding a head or flipping one more time (rather than “not”).

@David McFadzean Thanks for the response. My interpretation was based mainly on the use of the word ‘girls’ in the original post, as well as the way the computation was framed in the majority of the comments – G/(B+G). Also, in the ‘A Big Answer’ post,

http://www.thebigquestions.com/2010/12/22/a-big-answer-2/

this is made explicit by virtue of the example in the edit where one of the example family configurations is just ‘B’, and this is utilized in the computation that follows. This seems to make the intent pretty unequivocal to me. However I admit that adding the parents into the equation would bump the numbers up, but would not change the trend. I suppose you could also argue that the parents are not ‘interesting’ but that is perhaps a matter of debate.

I think we can agree though, that much of the controversy over this puzzle comes down to ambiguity in the way it is worded. As one of the other commenters pointed out, the sheer volume of comments and the continuing lack of consensus are a strong indication of that semantic ambiguity.

This issue of semantic ambiguity and statistics was recently a topic at the Decision Science News,

http://www.decisionsciencenews.com/2010/12/03/some-ideas-on-communicating-risks-to-the-general-public/

In the post they review several recent articles that focus on effective visualization and unambiguous descriptive techniques for communicating statistical information to the general public. Interestingly they also direct their attention at medical professionals, whom one might expect to be quite adept at handling such information. Nevertheless the quoted study found that given a fairly simple question about conditional probabilities and a particular test, the vast majority of doctors – doctors! – tended to confuse what they were really being asked for (the posterior probability) with something else (often the false-positive rate). When presented with ‘confusing’ or ‘ambiguous’ language only 1 in 24 got the right answer. When the group was presented, without any further training, with a re-worded question, this rate went up to 16/24.

The post contains several other good examples, and the referenced papers themselves are also quite interesting.

This is all to say that the computations involved in this problem, no matter what your take is on them – are all incredibly simple. Any one of the 3 or 4 variants that have been presented throughout the comments and related posts can be summarized in about 10 lines of python. I don’t think there is any dispute there. The issue seems to be primarily about which one of these variations is most appropriate given the presentation or exposition of the question.

Now for the final bit – the bet.

There is a very important pragmatic aspect to the bet, in my opinion. This again relates to the presentation of the question, and the terms on which any challenges are to be judged. In particular the semantics of the question are in no way ambiguous to professor Landsburg, which is not particularly surprising; there would be little point in posting anything if that were not the case. But given their shared professional circumstances he is more likely to be in agreement with his colleagues than not.

In my mind, the obvious controversy and implied ambiguity of this very interesting and even more lengthy thread, combined with this pragmatic reality still conspire to make this a very bad risk for any challenger.

It has made for some very interesting conversation though!

I’m not sure why there’s so much Math in the discussion.. the only issue here is whether you interpret the question as asking for

(i) E[g] / E[b+g], where the answer is 0.5, trivially

or

(ii) E[g/b+g], where again it is trivial to provide a case where the answer is not 0.5

That’s all the mathematics needed, everything else is a question of language, not math.

As for my $0.02 on that part – It’s a somewhat ambiguously written question, but I my impression on reading it was that it was more likely to be asking the fraction of the expected number of girls over the expected number of boys. It’s a more useful number in this context, it has a unique solution not dependant on other parameters which weren’t specified in the problem (number of families for e.g.).

Also, it’s quite clear that the intent of the question framer was to ask E[g] / E[b+g], and intent has to be taken into account when working with ambiguous language rather than precise mathematical notation.

[btw, I don't have time to think this through, but a few seconds thought makes me pretty sure that

the limit of E[g/b+g] as number of families goes to infinity is 50%.]

p.s. I didn’t have time to read most of the thread, sorry if I’ve duplicated what has been said before

So Steve,

Now Tom has finally let you understand where you were going wrong I hope you also re-read the things that Lubos wrote. Maybe even a little apology should be order….

Thomas,

I’m not only thinking of each family’s children sequentially. I’m thinking of all the births in the country sequentially. Generate the string of heads and tails, then draw cirles around the ‘families’ however you like. Then look for what effect the “stop on a boy” rule has. The effect it has is to make the string of births for a whole country always end on a boy. I compute the statistics before the country has its very last child. (If you compute statistics before each family has its last child, you’ll just get all girls.)

Thanks for the kind words. No, my frustration wasn’t addressed to you in particular. In fact your comments have been consistently substantive. It’s really that ‘alla youse guys’ could be a lot more effective if you didn’t get trapped inside your favorite solution procedures and dismiss people whose points you don’t understand.

Thomas,

I had trouble following your second paragraph at first, but I think we’re talking about the same thing. Which is more ‘appropriate’ I hesitate to say. Both models are very artificial–no second generation, for example. There’s so much smoke and heat about the problem statements that I find it hard to think clearly about them. But you have some physicists on line, interested in the problem, and some of those folks are trained extensively in making rubber meet road. If you want to understand the possibilities, just get the freaking ducks in a row as it were, I would bring some of them inside the circle.

Good luck.

Tom,

One more question for you . . . what makes you think I’m not a physicist and that I’m not trained to make the rubber hit the road?

Some people work on roads where the difference between success and failure relies very much on accounting for terms that depend on 1/K factors, and on making sure that you address the problem at hand, not one that you’d prefer to address. Changing the question so that the 1/K term doesn’t enter should not be confused with an approach that is consistent with making the rubber hit the road.

PhilT: Tom very clearly stated that he is addressing a different problem from the one that Steve stated. By explaining that he needs to omit one of the children to make the expected ratio be 1/2, Tom is implicitly acknowledging that the expected ratio is not 1/2 if he doesn’t omit one of the children from the count. Both questions are interesting and worth understanding, but they are different questions.

Here is a nice quote from a physicist named Edwin Jaynes who wrote much about the theoretical and practical aspects of statistical inference:

–

“This means that we must learn to define the problem much more carefully than in the past. If you examine the literature with this in mind, I think you will find that 90% of the past confusions and controversies in statistics have been caused, not by mathematical errors or even ideological difference; but by the technical difficulty that the two parties had different problems in mind, and

failed to realize this. Thinking along different lines, each failed to perceive at all what the other considered too obvious to mention. If you fail to specify your sample space, sampling distribution,

prior hypothesis space, and prior information, you may expect to be misunderstood — as I have learned the hard way.”

–

. . . from a paper entitled “Monkeys, Kangaroos, and N”:

http://bayes.wustl.edu/etj/articles/cmonkeys.pdf

Actually, I think this whole discussion is a good example of why people should not “agree to disagree” as pointed out in TBQ. Steve’s insults to Tom were uncalled for, but sometimes that happens in the heat of discussion, and I suspect Steve regrets them.

Thomas,

Fair enough. I am sorry if I gave offense. Your example is great, I’m an engineer in part and I would be the last person to throw away a 1/k factor unexamined. 1/k could be huge.

The question of whether I actually did change “the problem” so that the 1/k factor didn’t enter into it is still open. I modified an artificial restatement of the problem to produce a different artificial restatement of the problem. If we’re talking about the original problem, what about grandchildren? Is that factor negligible? More than 1/k? Less?

For people who

doesprefer to stay inside mathematics–I certainly don’t think that the parts of the car that don’t touch the road are somehow less important. Try making a car out of just tires.I’m afraid my point that the group here is weakened by its insularity still stands, though. I wish I could make that point without giving offense; I’ve enjoyed working with you.

Thomas,

Also, thanks for being careful about putting words in my mouth. But I can clarify one thing, in case it helps you bring anybody up to speed.

For the computer-modelling-based bet in the post above, I don’t just implicitly acknowledge that the fraction of girls deviates from 1/2 if we leave the final child in the count. I’ve said that explicitly, and more than once. It will be less than 1/2 for that case.I still don’t understand, though, how either of us can justify neglecting grandchildren. I suspect they may not be negligible.

Thomas,

In terms of the camps around here, I am really not some kind of “anti-1/k-ist.” The original problem statement notwithstanding, it’s interesting to be able to talk about tiny little countries. I know there are some folks focusing on the insignificance of the 1/k factor; Lubos’ comparison of 1/2k to sqrt(N)/2 is relevant for example. But my modification of the computer-simulation problem statement above was not that kind of argument. It is just as artificial as the one I derived it from.

I developed my case in order to focus attention on the “terminal half boy.” If I can make the whole effect go away so simply, then maybe the effect itself is simple and concrete. To get the discussion out of the abstract and into the particular. I figured Steve would prefer to listen rather than just hand over $5k.

I wrote a Java simulation for this problem, and the expected number of males is certainly not 50%, although it depends on the size of the initial population and the number of years the simulation runs.

The accumulate method in my code allows you to run a given number of trials, and furthermore to reduce the effect of randomness, each trial is run twice so that the second time, each coin flip for selecting the sex of a new baby happens the opposite way than it happened the first time. And no, the results of these trials are not each other’s inverses.

I believe the mathematics of the “remove the last boy” calculation, that if you drop the last boy, the expected ratio is 50%.

However: is there a good, short, intuitive explanation of why this works? I don’t understand Neil’s (Dec. 30, 1:02 am) explanation fully. Neil, could you expand a bit?

Phil,

You do not have to drop the last boy, just the last birth (in case the sequence is not complete.) In any case, as pointed out by others, the problem is equivalent to the sequence found by flipping a coin. Imagine that the families go at reproducing in turn, so that when the first family stops reproducing, the second family starts, and so on. You get a sequence like GGBGBBBGGG…. just as if you are flipping a coin. This sequence has an expected proportion of .5 tails (girls) if it ends randomly. But if you must always end on a head (boy), then the last head is non-random. This makes the expected proportion of tails less than .5 as stated by Steve. Tom’s trick is to remove the last flip. If the sequence is complete so the last flip is a head, you remove the non-random event and the expected proportion of tails is increased to .5. If the sequence is not complete and you remove the last flip, it doesn’t change the expected result of .5 because the last flip was random.

Thanks, Neil,

That helps. Let me think about it a bit.

Neil,

Your explanation doesn’t work for me. Specifically, “This sequence has an expected proportion of .5 tails (girls) if it ends randomly”.

Even without the last toss, not all sequences are equally likely. For instance, if there are four families, then “GGGBGBGGB” is not as likely as “GGGBBBGGB”, because the latter sequence *cannot happen*!

Similarly, “BBB” is the most likely sequence, with p=1/16, more likely than (say) “BGBGB” (p=1/64).

Therefore, I don’t think that explanation works. I don’t dispute the result being 1/2, just this explanation.

“…” means continued. Both your sequences can happen. In the first, family one has GGGB, family 2 has GB, family three has GGB, etc. In the second, the first has GGGB, the second has B, the third has B, the fourth has GGB etc. You can then order the families with decreasing probabilities.

Hi, Neil,

I was not referring to your sequence. I was picking arbitrary ones *for four families*. For four families, GGGBBBGGB is impossible (leaving off the terminating boy).

You are not specifying this problem precisely enough. There are two ways to calculate the results of the simulation you propose. Here is some javascript that can run in any browser:

// boys = 1

// girls = 0

function singleBirth() {

if (Math.random() > 0.5) { return 1 } else { return 0; }

}

function runFamily() {

var family = new Array();

family[0] = singleBirth();

var i = 0;

while (family[i] == 0) {

i++;

family[i] = singleBirth();

}

return family;

}

function countGirls(family) {

var count = 0;

for (var i=0;i < family.length; i++) {

if (family[i] == 0) count++;

}

return count;

}

var numRuns = 100000;

var percentSum = 0;

var totalNumBoys = 0;

var totalNumGirls = 0;

for (var j=0; j < numRuns; j++) {

var numFamilies = 4;

var numGirls = 0;

for (var i=0; i < numFamilies; i++) {

var family = runFamily();

numGirls = numGirls + countGirls(family);

}

var numBoys = numFamilies;

var total = numBoys+numGirls;

totalNumBoys = totalNumBoys + numBoys;

totalNumGirls = totalNumGirls + numGirls;

percentSum = percentSum + (numGirls/total);

}

alert("METHOD 1: "+percentSum/numRuns);

var totalTotal = totalNumGirls+totalNumBoys;

alert("METHOD 2: "+(totalNumGirls/totalTotal));

METHOD 1 will be (as you say) ~44%

METHOD 2 will be ~50%

The problem is in the original question:

“What percentage of the population is female [on average]” is ambiguous because the % of the population that is female is not, in the universe the problem describes, a symmetrical bell curve (where the meaning of “on average” would be unambiguous).

You and Lubos Motl are simply interpreting the meaning of “on average” differently. Neither you or Motl are right or wrong, you’re just interpreting things differently.

HarryH:

But the phrase in question is not “on average”. It is “in expectation”, which is unambiguous.

I think you’ll find the answer is;

10.99/25

I can prove it, I have the proof, but I do maths for my own enjoyment, as it should be, and therefore have no desire to prove to anyone I have done it. If you are really serious about maths and love its simplicity, i’d be happy to discuss it with anyone, provided they don’t steal my work.

Dr. Daniel Cloud

@DannyCloud – I’d love to know how you came up w/ 10.99/25. I won’t steal your work – I’m not a mathematician – i’m not even great at maths – but I love maths and am immensely curious how you arrived at that fraction.

Chris

I haven’t read all of the comments yet, but gender outcome is not merely a 50/50 chance. Sperm can survive for several days inside a woman, but the egg can only survive for about 24 hours. Gender development is strongly correlated to these times: if the couple has sex a couple of days before ovulation, X-chrom sperm (girls) will last longer than Y-chrom (boys) sperm. If a couple has sex on the day of ovulation, the faster X-chrom sperm will reach the egg first.

I think time of sex and ovulation should be accounted for in order to make the actual gender part of the equation realistic. Otherwise, it’s a weighted coin flip equation, not gender or genetics.

Since the question is, “What is the expected ratio of girls to boys?” and not, “What are the odds that each family will have a girl?” then I’ll take your bet, since you already proved that the expected ratio is 1/1 or 50%. (If you won’t accept those terms, I won’t take the bet, obviously). arg11@duke.edu

Alex: How much are you in for?

Landsburg is correct. As the number of families increases, the proportion of girls approaches 0.5. But for only four families, the ratio is closer to 0.44.

Here’s my R code, using 1,000 populations of 100 families each:

npops<-1000;

popratios<-1:npops;

for(j in 1:npops){

nfam<-100;

nboys<-0;

ngirls<-0;

for (i in 1:nfam){

exitfam<-0;

while(exitfam==0){

junk0) {

nboys<-nboys+1;

exitfam<- 1;

}

if (junk<0) {

ngirls<-ngirls+1;

}

}

}

popratios[j]<- ngirls/(nboys+ngirls);

}

mean(popratios)

Hrrmmmm…. ^^^The formatting for comments screwed up my R-code…

Here’s my simulation in R for a population of only 4 families, showing Landsburg is correct:

http://i834.photobucket.com/albums/zz266/mikenmar1/Rcode1.png

Here it is for a population of 100 families; the ratio gets closer to 0.5:

http://i834.photobucket.com/albums/zz266/mikenmar1/Rcode2.png

Quick python test:

import random

for num_couples in range(1,20):

results = []

for i in range(10000):

num_boys = 0

num_girls = 0

for d in range(num_couples):

while random.randint(1,2) == 1:

num_girls += 1

num_boys += 1

results.append((num_girls, num_boys))

fraction = sum(100.0 * ng / (ng + nb) for (ng, nb) in results) / len(results)

print “Expected fraction of girls for %d couples is %7.2f%%” % (num_couples, fraction)

And the results:

Expected fraction of girls for 1 couples is 30.76%

Expected fraction of girls for 2 couples is 38.71%

Expected fraction of girls for 3 couples is 42.22%

Expected fraction of girls for 4 couples is 43.99%

Expected fraction of girls for 5 couples is 44.88%

Expected fraction of girls for 6 couples is 45.93%

Expected fraction of girls for 7 couples is 46.28%

Expected fraction of girls for 8 couples is 46.84%

Expected fraction of girls for 9 couples is 47.21%

Expected fraction of girls for 10 couples is 47.48%

Expected fraction of girls for 11 couples is 47.57%

Expected fraction of girls for 12 couples is 47.99%

Expected fraction of girls for 13 couples is 48.10%

Expected fraction of girls for 14 couples is 48.23%

Expected fraction of girls for 15 couples is 48.30%

Expected fraction of girls for 16 couples is 48.50%

Expected fraction of girls for 17 couples is 48.50%

Expected fraction of girls for 18 couples is 48.80%

Expected fraction of girls for 19 couples is 48.78%

I am a physicist, and I believed the conventional explanation until I ran the test. I will study the maths more carefully now.

Given the fact that the measuring time is not specified, it is obvious that the best we can do is to calculate the average fraction of girls in a replicated experiment by measuring the fraction at a random year for each replication. When I simulate this using 100K replications, and 4 families, I get a fraction of 0.483038. So, in this (more justified) case, I believe Steve’s estimate is wrong.

hmmmmmmm, (I may have the number of m’s in your name wrong)

That’s interesting. I don’t think anybody else has posted simulations for the incomplete-families case. (I don’t recall Steve posting a numerical answer for that case either?)

I’d have expected the answer to come out somewhere between 0.44ish and 0.5, because your ensemble contains some countries that have terminated (0.44ish) and some that haven’t yet (0.5) (? I’m feeling uneasy about whether we’ve thoroughly proved that second point yet). But if that second point is true, then I think your result fits into the existing picture pretty well so far.

Countries that haven’t terminated yet could easily be above 0.5. For instance, for countries with one family and at least one child born, an incomplete country must be 1.0 (since it’s all girls so far).

For countries that haven’t terminated yet, the expected ratio depends on the selection criteria. For a country with N familes that hasn’t terminated after (say) 3N births, it’s going to be heavy on girls. For a country with N families that hasn’t terminated after 3N/2 births, it’s going to be close to 0.5, but still a bit heavy on the girls. And so on.

On the other hand, FAMILIES that haven’t terminated yet are always all girls. Still, that doesn’t necessarily increase the ratio. An incomplete family reduces the country by (a) exactly one boy, and (b) all the girls that would be born before that one boy [expected number of those girls: 1].

So it’s like removing one boy and one girl from the country’s offspring. That shouldn’t change the ratio much.

Also, I think the “removing one boy and one expected girl” way of looking at it means that incomplete families cannot move the expected ratio from one side of 50% to the other side of 50%. But I don’t have a proof or argument for that.

E[G/(G+B))] = \sum_{i_1=0}^{\infty}\sum_{i_2=0}^{\infty}\sum_{i_3=0}^{\infty}…\sum_{i_n=0}^{\infty}[\prod_{j=1}^{n}(\frac{1}{2})^{i_j+1})][\frac{g_0+\sum_{j=1}^{n}i_j}{p_0+n+\sum_{j=1}^{n}i_j}]

Paste that into

http://www.codecogs.com/latex/eqneditor.php

to view.

Let me explain this. Consider n couples, g_0 initial girls, and p_0 initial population. To calculate the expectation value of the ratio we need to consider all the possible child birth situations and the probability associated with each possibility. For instance all of the couples could have a boy, the probability of this occurring being (1/2)^n, the number of boys born would be n, the number of girls born would be 0, so the ratio would be (g_0 + 0) / (p_0 + n + 0). Now, there are a TON of different configurations. The first couple could do GB, and the rest boys. Maybe the first couple had a boy, the second GB, and the rest boys, etc. To consider all of these possibilities we need the summation I proposed where the indices are counting the the number of girls for each couple. The indices range from 0 to infinity because a couple could potentially just keep having girls without end, of course the probability of this happening dwindles exponentially. The expectation value has the form:

(sum over all states) [probability of configuration]*[ratio of females to total population]

Suppose a generation has N families. They will finish having children when they have had N boys. There are several statistical components to a question about the expected proportion of girls in a census. Here are some things that need to be considered:

1. All of the families could have had their boy. The expected proportion of girls in this case is roughly 1/2 – 1/(4N).

2. At least one family has yet to have a boy. In this case, the expected proportion of girls in the country is equal to 1/2.

So now we need to ask ourselves what we ‘expect’ to see when we take the census. It is somewhat like flipping a coin and assigning the value of ’1′ to heads and the value of ’0′ to tails. We will see a value of 0 or 1, but the expected value of the result is 1/2. Same for this puzzle. All of the families will have ‘terminated’ their reproduction with their last child, or they will not. But the expected proportion of girls is a weighted sum of the two expectations:

(1/2)*Pr[some families haven't had a boy yet]

+

(1/2 – 1/4N)*Pr[all families have had a boy]

But this is equal to

1/2 – (1/4N)*Pr[all families have had a boy]

so this is the way we should modify our expectation for the possibility that all the families have not terminated. If you want the answer to be ‘exactly’ 1/2, then you need to eliminate any possibility of all families having had their boy at the time of your census. To do this, you have to plan to take your census before every family has had at least one child, which would be an odd thing to do given we are interested in seeing the consequences of this particular birth policy.

As the Google interviewer, I would want to know Steve’s response to the following questions:

- The original question has several suppositions that do not relate to any sort of ‘real world’ scenario – every couple in a country wants to have a son, they stop when they get one, women can have children forever, etc. These are ridiculous items and were accepted at face value – why was that premise that the country has an infinite number of families not considered? Does assuming that the population of the county is infinite change the answer? Is this acceptable?

- As a follow up, if we go ‘whole hog’ and assume the country has an infinite population as well, what is the correct answer to the question?

- The bet appears to be based on the speed at which a series converges; after 3000 tries, the fraction of girls will be under 46.5%. What if someone comes along and suggests that you can choose the fraction of girls (under 50), but they get to choose the number of trials (k). Is the bet still on?

- As a follow up, does the bet adequately capture the terms of the original problem? Why or why not?

Finally, suppose someone comes along

Mark:

Here are my answers to your questions:

1) Why was the premise that the country has an infinite number of families not considered? Answer: Because then there are infinitely many girls and infintely many boys and it makes no sense to take the ratio. I think it’s fair to start by assuming that the question is supposed to make sense.

2) If we assume an infinite population, what is the correct answer? Answer: In this case the question makes no sense.

3) What if someone comes along and suggests that you can choose the fraction of girls (under 50), but they get to choose the number of trials (k). Is the bet still on? Answer: Absolutely, if they want to raise it above 3000. I will even stick with the fraction (about 44%) that I’ve already announced. If they want something much smaller than 3000, then the odds will still be with me, but I’ll stand a fair chance of losing.

4) does the bet adequately capture the terms of the original problem? Why or why not? Answer: That depends on what you mean by “the bet”. The correct answer to the original problem is “definitely not 50%, though the exact answer depends on the additional assumptions you make”. I am willing to bet that a panel of statistics professors will agree with that answer. Separately, I am willing to bet that the answer becomes about 44% if you make the particular assumptions I made in my followup post (e.g. number of families equals 4, etc.) Those are different bets, but both are entirely in the spirit of the original question and answer.

I have computed the expectation value with n=4 couples, initial number of girls as 4, and initial population at 8. I used my formula above and only let the indexes range from 0 to 10, instead of 0 to infinity of course. Here are the results:

http://www.wolframalpha.com/input/?i=sum+(sum+(sum+(sum+((4%2Bi%2Bj%2Bk%2Bl)/(8%2B4%2Bi%2Bj%2Bk%2Bl))(1/2)^4*(1/2)^(i%2Bj%2Bk%2Bl),+l%3D0+to+10),+k%3D0+to+10),+j%3D0+to+10),+i%3D0+to+10

The approximate form is 48.4%

Steve and Mark,

1) If I just walk up to you on the street and say I have infinitely many boys and infinitely many girls, then you can’t take a ratio without more information. But you can take the heads/flips ratio for an infinite number of coin flips.

3) We’ve been using

kfor the number of families, not for the number of trials! Can I plead that we keep to that convention?yes sorry k=families, not population or trials. Should read:

Does assuming that the number of families in the county is infinite change the answer? Is this acceptable?

If we assume an infinite number of families, what is the correct answer?

What if someone comes along and suggests that you can choose the fraction of girls (under 50), but they get to choose the number of families (k). Is the (original) bet still on?

Mark,

An example of a birth sequence for a generation with K families looks something like this:

B G B G G G B B G . . . B G B

The one interesting thing about this sequence — and the one thing that makes it different from any other ‘random’ binary sequence — is the fact that it will always terminate with the Kth boy born to the generation. It could never end like this:

B G B G G G B B G . . . B G G

Because of this, any computation of the expected proportion of boys or girls has to account for the possibility that the census will include the final boy in the count of children. That is what makes the expected proportion of girls different from 1/2. You should keep in mind, though, that the census doesn’t have to include the final boy. There just needs to be a nonzero chance that he’ll be counted, and this will cause the expected proportion of girls to deviate from 1/2.

If you let K be infinite, then the birth sequence will never stop and there will be no chance that any census based on a finite number of children will include the final boy, so the expected proportion of girls (or boys) will be 1/2.

On 30,000 simulations of 4 families each assuming an average maximum fertility of 30 children per family (normally distributed with sigma=2) I get slightly under 44% female.

Density and Q-Q Plots are here:

http://img254.imageshack.us/img254/8871/rplot.png

Annotated R code for the simulation is here:

http://pastebin.com/XmRF72ws

I will take your bet, but your method of solving this problem is simply incorrect. The correct answer is 50% and I don’t need statistic professors to demontrate it. Your mistake is assuming this country would only have only four couples (or any small number like that) AND assuming that the families would have their babies, then stop, then the population would be tallied. That is not the way the original question is worded. That is not the way nations work.

If we assume that this is a large nation of many generations, the number of families will be virtually infinite.

All you need to know is that every time a child is born, it has a 50% chance of being male or female. It makes no difference when a family starts or stops birthing babies. Each birth has a 50% chance and therefore the nation would be 50% female.

If you wait to tally the numbers after every family is done having babies then you are doing it wrong.

If you still want to bet with me, I will gladly put up $100.

Martin Maier: I accept your bet. Since you object to tallying the numbers after every family is done having babies, you can decide after how many (simulated) years to cut off the experiment. I’d suggested 30; you can go ahead and pick another number if you prefer. And since you object to the four-family assumption, tell me how many families you want to assume. Then I’ll tell you my prediction (which will not be 50%) and we can proceed.

Martin Maier: Choose to measure the ratio’s after the first year.

Jackson and others who’ve posted analytical solutions,

You’re not being ignored here. But we’ve gone through the process of adding these things up a number of times already and a certain amount of fatigue is probably setting in.

If you’re doing a single generation, could I ask whether you agree or disagree with the approach described in these two comments? If you like the approach, some important points are added in this comment.

What we’re calculating in those comments is the expected girl/kid ratio for a generation right before the final boy is born. It comes out to exactly 1/2, or so I say, but the math is simpler to read than the case where we go ahead and add that last little troublemaker in. For busy people it can help. If we’ve screwed up, I think that’s where to look for it.

Thanks

@Thomas

elegant

To summarize the correct interview answers then:

“This question makes no sense” – Probably best uttered immediately after the first sentence, with outstretched hand sitting bolt upright, when applying for a Logician position.

“As the number of families trends toward infinity, the fraction converges to 1/2″ – Bonus points for summing the right series which, as Steve has pointed out, most people up to now have not.

“Definitely not 50%, though the exact exact depends on the additional assumptions you make” – A good answer similar to above that assumes a non-infinite number of families.

“1/2″ – Pretty cagey; hopefully the interviewer will be so jaded that they will just move on.

“Have you read the Big Question blog?” – With fingers steepled and staring off into space; follow up with a strange cough on a negative response.

A real country, even a small one, will have population of (potentially) all ages, not 4 synchronized families. So the right simulation is to make some assumptions about life expectancies and fertile years and marriages, then run the simulation for several generations until the intitial ages become irrelevant. If the population is large enough so that an all-boy streak which will depopulate the country is negligibly probable, then the expected ratio is 50%. (And if not, the question is undefined – what is the “ratio” in a depopulated country?)

That is to say: in a real-world country, there will always be some unfinished family.

Jameson Quinn:

If the population is large enough so that an all-boy streak which will depopulate the country is negligibly probable, then the expected ratio is 50%.Interesting claim. How do you prove this?

As Tom has shown, the ratio is exactly 50% if there is some family still having kids. Thus, the way to have less than 50% females is for a lack of newly-fertile women with whom to make couples artificially extends the period when this is true. It is true that there still may be some young girl capable of eventually restarting the generational cycle – but it’s also intuitively clear that the chance of a hiccup of boys is higher when the overall population is lower, and that this also raises the chances of a permanent, depopulating streak of boys.

With one baby per year, the average couple will be fertile for 2 years. If fertility starts at 20, that means that if there are more than a few 10s of couples, the chances for a break in fertility quickly grow negligibly small. So, with reasonable demographic assumptions, I’d say a population of even 100 fertile couples – say, 7000 people or so – the analytic difference from 50% would not fit in a 64-bit floating point number.

Which of course still means you’d break even on your bet. You could roughly calculate an analytic solution of 49.9999999999999999999999%, make the bet, and know that you’d have a 50/50 chance of being closer than my 50% answer in 3000 monte-carlo trials. So: are you willing to stand by your 47% number, for the subset of countries which have exactly 4 families with children under fertile age? I would make that bet, using the “statistics profs decide the right procedure” option – which amounts to giving you slightly favorable odds that the statistics profs won’t decide your procedure is fairer.

Actually, I take that back; I’d have to insist on a 46.5% cytoff for the bet to be a reall worthwhile to me. Back-of-the-envelope, 4 couples with minor children, plus the possibility of a 0-child new couple, is 9 years of fertility distributed over the 18 infertile-minor years, which is around a 50% chance of having a currently-fertile couple (50% ratio) and a 50% chance of having all complete families (44% without counting grandparents). That averages out too close to 47% for comfort; Add in the uncertainty about whether the stats profs will choose my procedure, and I really need that extra half-percent safety margin.

I can put up $750.

My advice in general to people would be this:

I would never place a bet with someone who proposes taking a simple average of a set of items which have different “sizes”. Doing so is a common way of essentially changing the rules of a problem to produce results that are unexpected.

The formula proposed by Mr. Landsburg is something I would describe as:

what is the average of the “ratio of women to kids in a family” in this country. Which is clearly different than the number of women/kids in the population.

If the simulation was to take the proposed 12000 families, run the simulation and then take the number of girls/girls+12000 (since clearly there will be 12000 boys) then it would be a more accurate simulation of a reasonable interpretation of the question. You could also take the weighted average of the ratios in each family, but certainly not the simple average as proposed.

Dear Professor Landsburg,

As Jameson Quinn & Tom (and possibly others, I haven’t read all the posts) have pointed out, the expected ratio of girls to boys is 50% (under the usual assumptions of i.i.d. equally-probable births) — if you measure while at least one family is incomplete. That is, you have calculated the expected value based on an artificial method of considering a known number K of completed families. [Leading to an expected value which approaches 50%-1/(4K) as K becomes large.]

I don’t think anyone disputes your calculation of the fraction of girl children in K completed families. But the deviation from 50% is strictly a result of a biased sampling method, because by measuring the ratio after the completion of all families, one is necessarily sampling after the birth of a boy (in particular the Kth boy). The original question, we should recall, is “what fraction of the population [of the country] is girls?” The use of the word “country” implies a sizable population of diverse ages, and the fact of the matter is that not all families are complete at any one time. A measurement of the population would logically be made as of a fixed time — say midnight on 1 Jan 2011. Assuming that some families are still boy-less at that time, the odds that the last child born was male is only the “usual” 50%, and the expectation of the girl fraction is 50%.

So my claim is that your solution is not responsive to the original question, but that you are computing an interesting answer to a different question. Just as the ~30% value for the expected fraction of girl children in one family is answering a different question. And the fraction of females to males in that family (counting the parents) is yet another question, yielding an answer of ~45%.

So let’s change the simulation, or rather a thought experiment. Start with, say, a million males and a million females, distributed uniformly in age between 0 and 20 years. Each girl, upon reaching her 20th birthday, begins a family and continues in accordance with the given stopping rule. [We can ignore the boys, say by postulating polygamy if necessary.] Run the simulation for 100 years, and at that time, measure the fraction of females in the population. [If you want to make it a little more "lifelike", only measure the fraction of females among those less than 100 years old. Or 20.] What do you think the expectation of that fraction will be?

Howard W:

To see that you are wrong, consider a country with two families, where every family stops reproducing when it has a boy — but where the process artificially terminates after 2 years. That way, families are quite likely to remain incomplete, but the fraction of girls is 7/16, which is not the same thing as 1/2.

Details here.

Prof. Landsburg,

Once again, I do not question your result (7/16 in the example you gave), but it is still a “toy” problem which is not indicative of a nation.

The bias which leads you to an answer below 50% is not due to the focus on completed families per se; and your two-small-families example shows that well. The bias derives from the fact that the time at which you sample the population, is correlated to the quantity which you’re measuring. In the original example, the sample time — which is the completion of the Kth family — invariably follows a boy birth, which naturally reduces the girl fraction. In your two-small-families example, the bias is not as severe, but the sample time is still more likely than not to follow a boy birth. This new problem has less of a bias than the original (unlimited-family-size) problem — with an unlimited family size, the expected girl fraction for 2 families is 2ln2 -1 ~= 39%; with the family size limit the expected fraction is, as you say, 7/16 ~= 44%.

To show that this is a sampling bias issue, let’s consider those same limited-size families (earlier of one boy or two children). However, I propose an alternate sampling time. Rather than wait until two families are complete, let’s measure the girl fraction after two girls have been born in total. [This may well require more than 2 families.] So, we’ll let family 1 play out until it’s complete. If we haven’t seen two girls yet, start family 2, and continue until that family is complete, or we’ve seen two girls; and keep going until we eventually see two girls in total. You can do the math: the answer is that the expected fraction is 2-2*ln(2)=61+%. You may well say that my choice of sampling time is arbitrary and designed to favor higher girl-ratios; and I will agree with this objection. However, I contend that

this criterion is no more unnatural, in the context of measuring a nation’s population, than your criterion of following K specific families until they are complete.Let’s try to design a more neutral criterion. I suggest that we measure the fraction of girls born in a specific year. In our nation in that reference year, we’ll see N babies delivered. The genders will follow a binomial distribution pattern, and regardless of the specific value of N, the expected fraction of girls is 50%. Do you agree with this last?

Howard W: I absolutely agree with you that if you condiditon on the number of girls who have been born, you’ll get a different answer. For that matter, if you condition on the number of *children* who have been born, you’ll get the answer 1/2. But the problem asks for an expectation, not a conditional expectation.

Now you want to say (I think) that by sampling at a particular point in time, I am conditioning on that point in time, and therefore I too am computing a conditional expectation. But I claim that this expectation is (rather clearly, not in some sneaky way) built into the statement of the problem, when it aks “What

isthe expected fraction of girls?”. The word “is” implies, to me at least, and I’d have thought to anyone, that we are implicitly conditioning on the time being now, or more generally at some fixed time.This wasn’t intended as a test of what the meaning of the word “is” is; it never occurred to me that anyone might interpret it any differently than “What is the expected value

at this moment?”. If “this moment” happens to be a moment when all the families are complete, you get one answer; if it happens to be an earlier moment, you get a different answer, but neither is 1/2.Your more neutral criterion is to measure the fraction of girls born in a specific year. I absolutely agree that this is 50%. I find it very hard to think, though, that this addresses the original question, which asks about the *population*. This clearly seems to me to imply that people who were born last year and are still alive should count. If I asked “What is the population of China?” and somebody responded by quoting to me the number of one-year-olds in China, and insisted that that was a fair measure of population, I’d find that answer pretty difficult to accept.

You’d have a much better case going in the other direction — rather than saying that we should restrict the word “population” to one-year-olds, you could say that the word “population” ought to include the parents. That’s a legitimate criticism of some of these calculations. But it still won’t make the answer 1/2.

Howard W: Let me add this—

The “toy” example you refer to is a specific counterexample to this specific claim:

Do we agree that that claim has therefore been disposed of?

Prof. Landsburg,

I haven’t the time to post at the moment, but I at least wanted to acknowledge your extremely quick response, for which I thank you.

First, I never would have imagined we’d be discussing what the meaning of “is” is, and I got a great laugh out of that.

I think you’ve re-stated what I wrote very clearly — that your interpretation of computing an expectation over families is adding a conditioning, which is the cause of the deviation from 50%. This may or may not be so, of course. I’ll try to consider it over the course of the day, and try to clarify it if possible.

The point about measuring the fraction of girls in a single year was obviously not well-made — as you point out, this can not in any way be considered as a definition of population. But if, in each year, 50% of the children born are girls, does not the population achieve that ratio? [Naturally, assuming equal mortality.]

As to the reference about non-completed families, that was intended only to apply to the original problem statement, with unlimited families. The key point was that by waiting until K unlimited families are complete, we are conditioning on the birth of a boy. I computed the expectation of girl fraction for a 4-family case

if measured just prior to that final birthand obtained 50%; I generalized this to posit that the expectation was 50% if any of the families were incomplete. In the context of less-strong conditioning — your two-limited-families case — the expectation just prior to the final birth is surprisingly above 50%; I get 52+%. I attribute this to the fact that it’s more likely than not that the next-to-last child is a girl. [As opposed to the unlimited-families case, where the next-to-last child is equally likely to be of either gender.] [For the record, when making the above computation, it's necessary to define a birth order, and the above statements use serialized families. That is, the first family is completed, and then the second family begins. If the second family has just one child (a boy), the next-to-last child is the final child of the first family, which is only 25% likely to be a girl; if they have two children, the next-to-last child is their first-born, which is necessarily a girl. The two cases being equally likely, the chance of the next-to-last child being a girl is 5/8. Hence sampling after the next-to-last child introduces an upwards bias in the expected girl ratio.] So while I agree the specific claim — that incomplete families result in a 50% expectation of the girl fraction — does not travel well to other stopping rules, the point I was trying to make is that the expectation is dependent on the conditioning which is subtly imposed by the time at which we sample.By sampling at a fixed reference time, rather than after a specific birth, I think we avoid any such conditioning biases. That would be the natural method of measuring any national population — for example, the recently-completed US census took that approach. And I believe that the ratio will have a 50% expectation in that case.

Howard W: Thanks for your thoughtful comments. A few quick responses:

But if, in each year, 50% of the children born are girls, does not the population achieve that ratio?The population could achieve any ratio at all, because there could, for example, be a fluke year in which 100,000 out of 100,000 births are all girls. The question is what ratio does it achieve in

expectation. Here, I think, are the answers to that:1) Under many sets of plausible assumptions, the expected ratio is not .5. (Here, of course, “plausible” means plausible in the fictional context of a highly stylized world where everyone follows the same stopping rule, etc.)

2) There might or might not be some set of plausible assumptions under which the expected ratio is .5. So far, nobody in these discussions has produced those assumptions. (These would include precisely stated assumptions about mortality, fertility of children and grandchildren, etc.)

3) Moreover, it is not enough to produce a bunch of assumptions and

assertthat they yield an expected ratio of .5. It’s necessary to prove this.By sampling at a fixed reference time, rather than after a specific birth, I think we avoid any such conditioning biases.This is of course exactly what my proposed simulations do, as does the example I pointed you to. (I proposed a simulation that samples after 30 years; the example I pointed you to samples after 2 years.) Since these examples clearly don’t lead to expectations of 50%, I’m quite unclear on why you want to conclude that

I believe that the ratio will have a 50% expectation in that case.Prof Landsburg,

Well, that’s what I get for trying to quickly enter a post — a muddy post. I hope this one will be clearer.

First, as to sampling at a fixed time. Poor choice of words on my part. What I meant to say, is sampling at a time which is not correlated to an event which affects the metric. In your proposed simulation, because you don’t have a plausible mix of many ages, the sampling time of 30 years guarantees that the last child born is a boy. [Well, barring the astronomical chance that some poor woman bears 30 consecutive girls.] Similarly with the 2-year simulation: the last child born is more likely a boy (though not a near-certainty as in the first case). Hence my claim that the setup biases the measurement. In a more plausible simulation of a nation, all ages would be represented, in different stages of family formation, and establishing an arbitrary fixed time to measure was my approach to decouple the measurement time from the events. As you agree, if we sample after a fixed number of children, the expected fraction is 1/2; if we sample after the Kth boy has been born, we get an expected fraction less than 1/2; if we sample after the Kth girl has been born, we get an expected fraction more than 1/2.

Second, I attempted to extrapolate from the agreed statement that the expected value of the fraction of girls being born in any year is one-half, to the proposition that the nation’s fraction would tend to 1/2 as well. What I was trying to get at — and failed — is that the one-year period is arbitrary. The same statement about expected fraction of girls would apply to a period of 2 years, or 10, or 30, would it not? Now suppose that in our hypothetical country, everybody died exactly on their thirtieth birthday. [I believe this was the premise of a sci-fi movie some years ago.] The population at any instant would be precisely the number of children born in the previous 30 years. So would not the expected fraction of girls be 50% ?

I hope this was clearer, and thanks again for your replies.

HowardW:

Now suppose that in our hypothetical country, everybody died exactly on their thirtieth birthday. [I believe this was the premise of a sci-fi movie some years ago.] The population at any instant would be precisely the number of children born in the previous 30 years. So would not the expected fraction of girls be 50% ?Without some additional assumptions (and I’m not sure what they’d be) this is surely wrong. You’re looking at the expected fraction of girls born in the past 30 years, or more generally the past n years. Unless n=1, that expected fraction is not 1/2.

Prof Landsburg,

This sounds promising. You agreed that in one year the expected value of the fraction would be 50%. I came to that conclusion by saying that there would be some (unknown) number of births N in a year which would be distributed in a binomial fashion, and regardless of N the expected value came to 50%. Over 2 years, the number will be some other value N’ (somewhere in the neighborhood of 2N), but again those births will be distributed binomially. Why would the expectation be different from 50% in this case?

HowardW: You might have another look at http://www.landsburg.org/alt.txt , which does the explicit computation over two years for a country with two families.

HowardW: As to why it comes out differently for two years than it does for 1 year, let G1 and B1 be the number of boys and girls born in year 1 and let G2 and B2 be the number of boys and girls born in year 2. We have E(G1/G1+B1) = E(G2/G2+B2 | G1,B1) = 1/2. Why would you expect to be able to get from here to E(G1+G2/G1+G2+B1+B2) = 1/2 ?

Prof. Landsburg,

I apologize for the late reply. But your point, I take it, is that N2 has a positive correlation with f1. [I use f1 as shorthand for G1/(B1+G1), and N2=B2+G2 per your usage.] And therefore the final fraction f, which is an N-weighted average of f1 and f2, has an expectation which is below the individual expectations of f1=f2=1/2. This sounds reasonable. I’m currently trying to describe the effect in a different manner, as well as looking at how the effect evolves in time.

This is no doubt the lesson you intended to impart with the two examples explicitly worked out. [K completed families and 2 families/2 years.] Perhaps I was just being thick, but those examples did not strike me as representative cases for a nation, whose population is always evolving, so does not seem to be well described by a process with a definite end. Hence my earlier impression (which appears to be ill-founded to me right now) that the biases in those examples were due to termination with the last birth being more likely (or certain) to be a boy; in a real nation, the maternity wards are continuously in use, and one would expect that the last birth before the census time would be equally likely to be of one gender or the other. Not really an excuse for not catching on to your intent, just an explanation of my thought trajectory.