# 6.7. The Apocalypse

> In the new post-apocalyptic world, the world queen is desperately concerned about the birth rate. Therefore, she decrees that all families should ensure that they have one girl or else they face massive fines. If all families abide by this policy-that is, they have continue to have children until they have one girl, at which point they immediately stop-what will the gender ratio of the new generation be? (Assume that the odds of someone having a boy or a girl on any given pregnancy is equal.) Solve this out logically and then write a computer simulation of it.

## Hints

> Observe that each family will have exactly one girl.

So it can either be 1 girl - 0 boy, 1-1, 1-2, 1-3. So 1-1/(0.5)^n.

> Write each family as a sequence of Bs and Gs

* G
* BG
* BBG
* BBBG
* ...
* it becomes more and more improbable


> You can attempt this mathematically, although the math is pretty difficult. You might find it easier to estimate it up to families of, say, 6 children. This won't give you a good mathematical proof, but it might point you in the right direction of what the answer might be.

With 6 children, ratios might be

* 1-0, with prob 1/2
* 1-1, with prob 1/2 * 1/2
* 1-2, with prob (1/2)^3
* 1-3, with prob (1/2)^4
* 1-4, with prob (1/2)^5
* 1-5, with prob (1/2)^6

> Logic might be easier than math. Imagine we wrote every birth into a giant string of Bs and Gs. Note that the groupings of families are irrelevant for this problem. What is the probability of the next character added to the string being a B versus a G?

1/2

> Observe that biology hasn't changed; only the conditions under which a family stops having kids has changed. Each pregnancy has a 50% odds of being a boy and a 50% odds of being a girl.

## Solution

On average, families will have 1 boy and 1 girl. So the ratio is 50%.