TITLE: What is the expected number of coin tosses needed to obtain a head?
QUESTION [6 upvotes]: Due to my recent misunderstandings regarding the 'expected value' concept I decided to post this question. Although I have easily found the answer on the internet I haven't managed to fully understand it.
I understood that the formula for the expected value is:
$$E(x) = x_1p_1 +x_2*p_2 +...+x_np_n$$
The x's are the possible value that the random variable can take and the p's are the probabilites that this certain value is taken.
So, if I get a head on the first try, then  $ p_1 = \frac{1}{2} , x_1 = 1 $
If I get a head on the second try, then $ p_2 = \frac{1}{4} , x_2 = 2 $
And then, I woudl have that:
$$E(x) = \frac{1}{2}1+ \frac{1}{4}2 +...$$
So my reasoning led me to an inifnite sum which I don't think I can't evaluate it that easy. In the 'standard' solution of this problem, the expected value is found in a reccurisve manner. So the case in which the head doesn't appear in the first toss is treated reccursively. I haven't understood that step.
My questions are: is my judgement correct? How about that reccursion step? Could somebody explain it to me?

REPLY [3 votes]: To make ends meet... You have been explained by several users that, looking at the toss process itself, one sees that the expectation $E(X)$, that you know is $E(X)=S$, with $$S=\sum_{n\geqslant1}\frac{n}{2^n},$$ solves the relation $$E(X)=1+\frac12E(X).$$ It happens that one can also show directly that $$S=1+\frac12S,$$ this relation following from a shift of indexes. To do so, note that $S=R+T$ with
$$R=\sum_{n\geqslant1}\frac{1}{2^n},\qquad T=\sum_{n\geqslant1}\frac{n-1}{2^n},
$$
hence, using the change of variable $n=k+1$, $$T=\sum_{k\geqslant0}\frac{k}{2^{k+1}}=\frac12\sum_{k\geqslant0}\frac{k}{2^k}=\frac12\sum_{k\geqslant1}\frac{k}{2^k}=\frac12S,$$
hence the proof would be complete if one knew that $$R=1.$$ To show this, use the same trick once again, that is, note that $$R=\frac12+\sum_{n\geqslant2}\frac{1}{2^n}=\frac12+\sum_{k\geqslant1}\frac{1}{2^{k+1}}=\frac12+\frac12\sum_{k\geqslant1}\frac{1}{2^{k}}==\frac12+\frac12R,$$ hence the proof that $S=2$ is complete.