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 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.
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. The argument, which relies on conflating an expected ratio with a ratio of expectations, is wrong.
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 all to your lemma, your lemma is invalidated, and if your lemma is invalidated, then so is your whole argument. It doesn’t make a bit of difference whether 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 Animal gives 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 no sex 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, is
E(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 answer small, but that doesn’t change the fact that the original reasoning is 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 me of changing the problem midstream — because I am insisting on sticking to the original problem
d) 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”.
And we 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 are in 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:
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”.
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. 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.
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 for
On 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 N children total, then we calculate E(G/(G+B)) for the first N-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 “… most people 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 family we 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 bet
Do 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 certain country 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 certain c in the set C …” ?
If this an appropriate translation, then it would seem that the following would be an appropriate translation of the question:
“Let C be the set of countries where everyone wants to have boy. For a given c 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).