Calculate expected value based on geometric series Given is the following question: Person x gives birth to children until two children with the same gender are born in succession. What is the expected number of children?
So, if (G= girl, B=boy):


*

*GG or BB, then the probability is: $2*(1/2)^2$

*BGG or GBB: $(1/2)^3$

*GBGG or BGBB: $(1/2)^4$


and so on. Hence we have:
E(X) = $2*2(1/2)^2+3*(1/2)^3+4*(1/2)^4+...$
which can be written as
(1) E(X) = $1/2*(2+3*(1/2)+4*(1/2)^2+5*(1/2)^3+...)$
or as
(2) $1/2*E(X) = 1/2*(2*(1/2)+3*(1/2)^2+4*(1/2)^3+5*(1/2)^4+...)$
what I do not understand is then the following line in the script:
(3) $1/2*E(X) = 1/2*(2+\mathbf{1/2}+(1/2)^2...)$
Is the prof subtracting (2) from (1)? If so, where is the (1/2) in bold in (3) coming from?
 A: Yes, the professor is subtracting (2) from (1), and letting the $2$ term in (1) stand on its own (thus the $2$ term in (3)), then aligning the terms afterward. So the $\frac{1}{2}$ comes from $3 \cdot \frac{1}{2} - 2 \cdot \frac{1}{2}$. Similarly, the $\left(\frac{1}{2}\right)^2$ comes from $4 \cdot \left(\frac{1}{2}\right)^2 - 3 \cdot \left(\frac{1}{2}\right)^2$. Etc.
A: A monospace font with spaces may make it easier to see the subtraction:
(1)     E(X) = 1/2 * ( 2 + 3*(1/2) + 4*(1/2)^2 + 5*(1/2)^3  + ... )

(2) 1/2*E(X) = 1/2 * (     2*(1/2) + 3*(1/2)^2 + 4*(1/2)^3 + ... )

(3) 1/2*E(X) = 1/2 * ( 2 +    1/2  +   (1/2)^2 +   (1/2)^3 + ... )

As an alternative approach, suppose the expected number of children is $\mathbb E[X]=C$


*

*Have the first child:


*

*Since you do not yet have two consecutive children of the the same gender, the expected number of extra children is $C-1$.  Move to the next step to have the next child


*Have the next child: 


*

*With probability $\frac12$ this child is the same gender as the previous child, so stop; 

*With probability $\frac12$ this child is not the same gender as the previous child, so you are in the same situation as before and the expected number of extra children is again $C-1$ and you repeat this step



So $C-1= 1+  \frac12 (C-1)$ with the solution  $\mathbb E[X]=C=3$
