# What is the expected number of children until having at least a girl and a boy?

Source: (Harvard Statistics 110: see #17, p. 29 of pdf).

A couple decides to keep having children until they have at least one boy and at least one girl, and then stop. Assume they never have twins, that the "trials" are independent with probability 1/2 of a boy, and that they are fertile enough to keep producing children indefinitely. What is the expected number of children?

Solution: Let $X$ be the number of children needed, starting with the 2nd child, to obtain one whose gender is not the same as that of the firstborn. Then $X-1$ is Geom (1/2), so $E(X) = 2.$ This does not include the firstborn, so the expected total number of children is $E(X + 1) = E(X) + 1 = 3.$

My argument: Because of symmetry and for concreteness, we can assume that the firstborn is a girl. Let $X$ be the number of girls before the first boy. Then, $X$ is Geom (1/2). So, the expected total number of children is $E(X)+1=(1-p)/p +1= (1-0.5)/0.5+1=2.$ QED.

Why would mine be incorrect?

• That can't be right, and you can see that by noting that the MINIMUM number of children is 2. If the expected number of children = the minimum number of children, it must be that there is no possibility of having more children than the minimum number - otherwise the expected number of children would be greater than the minimum number... can you see the flaw in your argument? Hint: it has to do with the assumption of a Geometric distribution. – jbowman Mar 31 '18 at 18:46
• You forgot to count the first child. – whuber Mar 31 '18 at 20:46
• @jbowman Intuitively you're right. But I can't arrive to the rigorous mathematical formulation. The answer below is flawed. – Abdu Magdy Apr 1 '18 at 18:20
• @whuber Why? The first child is a girl by assumption. And it's included within $E(X)$ – Abdu Magdy Apr 1 '18 at 18:21
• The first child is a girl only if $X>0$; if $X=0$, there are no girls born before the first boy. Combine this with @whuber 's comment and you should be able to see why the source solution is correct. – jbowman Apr 1 '18 at 19:26

The problem is actually formulated as a negative binomial distribution with $r=1$ and $p=1/2$: number of successes with probability $p$ before $r$ failures. In this case you say that a success is a child of the same gender as the first one. The trick in applying neg binomial is related to the mistake you made in the solution: adding the first child. You do not have a definition of a success until you get the first child.

So, the solution is set up as follows. We get the first child, note the gender G. Then we start the negative binomial experiment cranking up children until a child of an opposite gender "not G" arrives, a failure. This way the solution is: 1 (first child of gender G) + mean number of children of the gender G + 1 (first child of opposite gender "not G").

The mean of negative binomial is $\frac p {1-p}$, hence the solution: $$1+\frac p {1-p}+1=\frac {2-p} {1-p}=3$$

See here: https://en.wikipedia.org/wiki/Geometric_distribution. There are two parametrization of the geometric distribution:

1. You compute the number of trials before success, here the mean is $1/p$;

2. You compute the number of failures before success, here the mean is $(1-p)/p$.

In the first case, you have $P(X = 0) = 0$ and in the second case $P(X = 0) = 1/2$. All this to say you simply use the wrong formula for the mean.

Once you have set the gender of the first child, you then look for the number of trials you need to get the other, letting that be $X$. Hence you should have $E(X) + 1 = (1/.5) + 1 = 3$.

• Might be a little clearer if you relate that $P(X=0) = 1/2$ back to the assumptions the OP is making, specifically, that the firstborn is a girl, but that the formula he's using has a 50% probability that no girls are born before the first boy. But you obviously figured it out! – jbowman Mar 31 '18 at 18:52
• @Perochkin I think you confused the things. According to the resource you provided: 1- the right column of the table: counting the number of failures before the success. Support = {0, 1, 2, ...}. Mean = $(1-p)/p$. 2- the left column of the table: counting the trials till the first success (i.e. you include the first success in counting the trials.). Support = {1, 2, ...}. Mean = $1/p$. In my argument I chose the first approach. Hence, the extra $1$ (belonging to the 1st boy [the success]) after $E(X)$. – Abdu Magdy Apr 1 '18 at 18:26
• In your argument, you chose the second approach. As a result, you don't need the extra one, because the success (the boy) is already counted by $E(X)$. Your argument needs revision, or I'm missing something. :) – Abdu Magdy Apr 1 '18 at 18:26
• Simply mixed up the cases. I think it's fine now. Thx. – Perochkin Apr 2 '18 at 13:50