2/16/2009

02-16-09 - Amusing Word Problem

Found this and it confused me for a second :

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?

Please settle this argument for me. Will it be 50/50?

(assume the a priori chance of boy or girl is 50/50 , and each family stops at its first boy).

13 comments:

Sylvain V said...

percentage of girls = sum of 0.5^n for n=1 to infinity.

Also known as 1: there won't be any number between 1 and the binary number 0.1111111111111111... So proportion of man = almost 0.

Also known as man paradise country :)

ryg said...

if the chance for girl:boy is 50:50, then you'll have exactly 50% girls in the resulting population (with an average family having 2 kids).

(as long as you don't start killing girls, it doesn't make a difference how many kids each family gets and for what reason - every time they decide to have a child, it's a 50:50 chance, and that's all that matters for the resulting population).

ryg said...

and, same as with the monty hall problem, the "birthday paradox" and other counterintuitive stochastical phenomena, the best way to not make a fool of yourself is to just Shut Up And Calculate(tm) first, then figure out the "why" later :)

cbloom said...

" and, same as with the monty hall problem, the "birthday paradox" and other counterintuitive stochastical phenomena, the best way to not make a fool of yourself is to just Shut Up And Calculate(tm) first, then figure out the "why" later :)"

Yes and no. I find it's pretty easy to do the calculations wrong for these kind of things if you don't work on the right variables. When your calculation tells you something strange it's useful to have an idea of the answer intuitively.

Sylvain V said...
This comment has been removed by the author.
cbloom said...

Sly, there's a little error in your maths.

It should be :

fraction of boys = sum of 0.5^n * (1/n) for n=1 to infinity

There are these possibilities :

B
GB
GGB
GGGB

first one happens 50% of the time, next 25% of the time, next (0.5)^3 , etc.

In first case its 1/1 boys, second case is 1/2 boys.

This sum can be done exactly, it's a series expansion of ln(2) = 0.69315

69.3% boys

Anonymous said...

I always do a Monte Carlo simulation to be sure:

int boys = 0;
int girls = 0;
Random rnd = new Random();

for (int i = 0; i < 10000000; i++) {
while (true) {
if (rnd.nextBoolean()) {
boys++;
break;
}
girls++;
}
}
System.out.println("boys/girls = " + (float)boys / girls);

Sylvain V said...
This comment has been removed by the author.
Unknown said...

Here is a simple calculation:

Let X = # of tries until boy
Let Y = sex of first child

Then E[X] = E[X|Y=male]Pr[Y=male] + E[X|Y=female]Pr[Y=female]

Now, E[X|Y=female] = 1 + E[X]

Plugging into above, E[X] = 1*1/2 + (1+E[X])*1/2.

Solving, we get E[X] = 2. So the answer is 50%

ryg said...

"Yes and no. I find it's pretty easy to do the calculations wrong for these kind of things if you don't work on the right variables. When your calculation tells you something strange it's useful to have an idea of the answer intuitively."
Except it also works the other way round, where you end up tweaking your calculations until it agrees with your intuition, and intuition is usually a pretty bad guide on anything involving probabilities. This problem being a prime example. It's pretty straightforward to transform the problem description into some code that simulates it (as klon did), but it's tremendously easy to go wrong when you try to calculate the answer directly.

That program converges towards a rate of 50% boys (or at least it did here). You can derive the same directly: Every family obviously has exactly 1 boy, so the question is how many girls. The expectation works out to sum(n=1;inf) (n-1)*2^(-n) = 1 (50% chance for no girls, 25% for 1 girl, 12.5% for 2 girls etc.). In other words the average family in that setting has one boy and one girl, and since expectations are linear, the same goes for the whole population.

Your formula first computes the expectation of the ratio, which obviously doesn't agree with the ratio of the expectations in this case (or in general, for that matter); only the ratio of expectations has a plausible interpretation (namely, an urn with E[boys] blue balls and E[girls] red balls from which we draw random balls and check which color they are), while I don't see any such thing for the expectation of ratios. I'm quite certain that my interpretation is both plausible and correct :), but it would still help immensely to have a model of what's going on in the other interpretation to be able to point our where it's going wrong.

cbloom said...

Rats, nobody fell for my trap.

There are a number of ways you can reason about this and get it wrong and I find them all amusing. The flaw in my first post is that it's summing percentages which of course doesn't give you the overall expected percentage.

Jim, I really like that expectation value way.

The simplest way I found was to count the number of girls, or count the number of kids total. (you know the average number of boys is 1)

The number of kids is

1/2 + 2*1/4 + 3*1/8 + 4*1/16 ...

= Sum n * (1/2)^n

which can be solved by differentiating the geometric sum by d/dr

and the answer is = 2 kids average, so it must be 50/50

cbloom said...

There's another way you can prove it, by induction.

The couple has one child. The distribution is obviously equal at that point.

Now if the couple has had N children and the distribution of boys and girls is even, then if they have 1 more, they are adding 1 boy or 1 girl to the set with equal probability, thus the distribution must stay even.

At 1 child it's even
If it's even at N children it's even at N+1
Therefore it's always even

You can see this :

B (1/2)
G (1/2)

B (1/2)
GB (1/4)
GG (1/4)

B=1/2 + 1/4 = 3/4
G=1/4 + 2/4 = 3/4

B (1/2)
GB (1/4)
GGB (1/8)
GGG (1/8)

B = 1/2+1/4+1/8 = 7/8
G = 1/4+2/8+3/8 = 7/8

etc

Aaron said...

It's a trick question because you left out sex-selective abortion and infanticide.

I prefer to do it experimentally: http://www.msnbc.msn.com/id/5953508

54.5% boys.

old rants