A Bernoulli trials problem Two parents decide to have children until they have 3 children of the same gender one after another (3 in a row). If p(boy)=p(girl)=1/2, how many children are they expected to have?
I have tried to draw a tree diagram to analyse the problem, but i can't generate a useful expression for the probability that a 'success' will happen on the nth trial.
So far P(3)=1/4, P(4)=1/8, P(5)=1/8, P(6)=3/32, P(7)=3/64, P(8)=5/128 and P(9)=1/32.
I have read a similar article on this forum about finding E(x) and Var(x) for 2 consecutive successes, but generating an expression here is far more difficult. In the case of first 2 consecutive successes in k trials, every success must be followed by a failure until the (k-1)th trial. Here not every success needs to be followed by a failure, though 2 consecutive successes must be followed by a failure until the (k-2)th trial.
many thanks,
Yun Fei
 A: They have a kid, cost $1$. We will add this at the end. 
After the first kid, the parents are in one of two states: State A if the two preceding children are of the same sex (so they are almost there); State B is there is a previous child, but they are not in State A.
Let $a$ be the expected number of additional children if they are in State A, and $b$ the expected number of additional children if they are in State B.
If they are in State A, then with probability $\frac{1}{2}$, they get their three in a row, and breeding is over.  And with probability $\frac{1}{2}$ they go into State B, and their expectation becomes $b$. The cost in either case is $1$ more child. Thus
$$a=\frac{1}{2}(1)+\frac{1}{2}(1+b).$$
If they are in State B, then with probability $\frac{1}{2}$ they get a child of the same sex as the previous one, and enter State A. With probability $\frac{1}{2}$ they get a child of the opposite sex, and stay in State B. Thus
$$b=\frac{1}{2} (1+a)+\frac{1}{2}(1+b).$$
Solve. We get $b=6$. Add the initial $1$ mentioned in the first paragraph. The mean number of children is $7$.
Remarks: $1.$ We can also express the expectation as a series, by calculating the probability that breeding ends after $3$ trials, $4$, and so on. The seres can be summed explicitly. But the conditional expectation approach we used above is much smoother, and is of wide applicability.  
$2.$ I would prefer a phrasing in terms of coin tossing, since in fact boy births and girl births are not equally likely. And the tacit independence assumption that we made is also not correct. 
A: Let $t_i$ denote the expected number of children to be born for 3 of the same sex to be born consecutively, after $i$ children of the same sex were born. Thus, $t_3=0$ and one is looking for $t_0$. Conditioning on the sex of the next child, one gets $t_0=1+t_1$, $t_1=1+\frac12t_1+\frac12t_2$ and $t_2=1+\frac12t_1$. Hence $t_0=7$.
For example, assume the last children born are ...MFMFF. Then $i=2$. If the next child is F, one goes to $j=3$ and the mean time to wait after this step is $0$ since the last children born are ...MFMFFF. If the next child is M, one goes back to $j=1$ and the mean time to wait after this step is $t_1$ since the last children born are ...MFMFFM. Thus, $t_2=1+\frac12\cdot0+\frac12t_1$. Likewise for $i=0$ (always goes to $1$) and for $i=1$ (goes to $2$ or to $1$).
