# Expected value problem: a couple stops having children as soon as they have a child that has the same gender as their first

Givens:

• $p$ is a real number with $0 < p < 1$
• Child is a boy with probability $p$
• Child is a girl with probability $1-p$
• Anna and Ben stop having children as soon as they have a child that has the same gender as their first child.
• Random variable $X$= number of children that Anna and Ben have

Required: $E(X)$.

I know that I need to use the fact that $\sum_{k=1}^{\infty} k x^{k-1} = 1/(1-x)^2$ but I don't know how.

Could someone please explain/show how answer this question?

• They way to solve this, is to compute the conditional expectation based on the first child. If you have first boy, you get 1 + the expected value of an geometric random variable with success probability $p$, which is $1/p$. If you have girl you get the 1 + expected value of an geometric random variable with success probability $(1-p)$, which is $1/(1-p)$. You then get the total expected value, as $p(1+1/p)+(1-p)(1+1/(1-p))=3$. (You need the described fact, to prove the formula for expected values of geometric random variables ).. This might be a little, but that is roughly the way to go. – Dimitar Ho Dec 2 '14 at 23:11
• Let me know, if you need a full answer – Dimitar Ho Dec 2 '14 at 23:16
• @DimitarM.H. It would be great if you could post the full answer – Tom Dec 2 '14 at 23:24
• Perhaps it is a trick question. The first child they have has the same gender as their first child, and they stop having children as soon as they have a child that has the same gender as their first child. – Henry Dec 2 '14 at 23:33

## 2 Answers

Case 1: Getting at first a boy and at last a boy

The probabiltiy to get first a boy and at last a boy in n attempts is

$p \cdot (1-p)^{n-2}\cdot p$

The expected value is $\sum_{n=2}^{\infty } n\cdot p^2 \cdot (1-p)^{n-2}$

Now you can make an index shift: $k=n-1 \Rightarrow n=k+1$

$\sum_{k=1}^{\infty} (k+1) \cdot p^2 \cdot (1-p)^{k-1}$

$=\sum_{k=1}^{\infty} 1 \cdot p^2 \cdot (1-p)^{k-1}+\sum_{k=1}^{\infty} k \cdot p^2 \cdot (1-p)^{k-1}$

factor out $p$ and $p^2$

$=p\sum_{k=1}^{\infty} 1 \cdot p \cdot (1-p)^{k-1}+p^2\sum_{k=1}^{\infty} k \cdot (1-p)^{k-1}$

• $\sum_{k=1}^{\infty} 1 \cdot p \cdot (1-p)^{k-1}=1$
• And from your formula you know, that $\sum_{k=1}^{\infty} k \cdot (1-p)^{k-1}=\frac{1}{(1-(1-p))^2}=\frac{1}{p^2}$

Thus we get $p+\frac{p^2}{p^2}=p+1$

Case 2: Getting at first a girl and at last a girl

The expected value is $\sum_{n=2}^{\infty } n\cdot (1-p)^2 \cdot p^{n-2}$

The further calculations are similar. The result, in this case, is $2-p$.

• but how do I get $E(X)$ from here? do I add $\frac{1}{p^2}$ and $2-p$? – Tom Dec 3 '14 at 2:39
• @Tom For the first case we have the expected value p+1. And if you do similiar calculations for the second case, you will get 2-p for the expected value. In total $(p+1)+(2-p)=3$. – callculus Dec 3 '14 at 2:42
• @Tom You do not add only $\frac{1}{p^2}$. Note that $\sum_{k=1}^{\infty} k \cdot (1-p)^{k-1}=\frac{1}{p^2}$. Thus $\color{blue}{p^2}\sum_{k=1}^{\infty} k \cdot (1-p)^{k-1}=1$ – callculus Dec 3 '14 at 2:47

Assuming the problem is not a silly trick, notice:

$$E(X)=E(X|\text{first child is male})P(\text{first child is male}) \\ + E(X|\text{first child is female})P(\text{first child is female})$$

by the total expectation formula. We are given the two probability values: the first is $p$, the second is $1-p$. Now $X|\text{first child is male}$ is $1+G_p$, where $G_p$ is a geometric random variable with parameter $p$. This is because they have a male child (which counts for one child), and then wait for an event with probability $p$, having $G_p$ children in the process. Similarly $X|\text{first child is female}$ is $1+G_{1-p}$.

Can you finish the problem from here? For checking purposes, I think the final answer should be $3$. (Note that this requires that that $p$ cannot be $0$ or $1$; indeed in either of these cases it is trivial to see that $X$ is always $2$, so $E(X)=2$.)

• so $G_{p}= \frac{1}{p}$ and $G_{1-p}= \frac{1-p}{p}$ then $E(X)=(1+\frac{1}{p})*p+(1+\frac{1-p}{p})*(1-p)$ after expending I get $\frac{p^2+1}{p}$. How do I go from here? – Tom Dec 3 '14 at 1:42
• That's almost right: you should have $(1+1/p)p+(1+1/(1-p))(1-p)=p+1+(1-p)+1=3$. – Ian Dec 3 '14 at 1:55