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?
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$.)