Expectation of the square of a geometric random variable Let $X$ be a geometric random variable with success parameter $p$. I am wondering how I could calculate $E[(X^2)]$, that is the expectation of the square of a geometric random variable. I know that for just $E(X)$ we can calculate it by differentiating a power series, but I'm unsure of how to carry this over to $E[(X^2)]$. I've tried to do this by using the fact $E[(X^2)] = E(X)+ [E(X(X-1)]$.
 A: This answer is kinda late but I think this solution can be easier to understand since you know how to get $E[X]$ using differentiation.
We should solve $E[X(X-1)]$ but we can use the same differentiation method for it:
$E[X(X-1)] $
$= \sum_{k=1}^{\infty}k(k-1)p(1-p)^{k-1}$
$= p\sum_{k=1}^{\infty}k(k-1)(1-p)^{k-1}$
$= p\sum_{k=1}^{\infty}k(k-1)(1-p)^{k-2}(1-p)$
$= p(1-p)\sum_{k=1}^{\infty}k(k-1)(1-p)^{k-2}$
$= p(1-p)(-\frac{d}{dp}\sum_{k=1}^{\infty}k(1-p)^{k-1})$
$= p(1-p)(-\frac{d}{dp}(-\frac{d}{dp}\sum_{k=1}^{\infty}(1-p)^{k}))$
$= p(1-p)(\frac{d}{dp}(\frac{d}{dp}\sum_{k=1}^{\infty}(1-p)^{k}))$
$= p(1-p)(\frac{d}{dp}(\frac{d}{dp}(\frac{1}{p}-1)))$
$= p(1-p)(\frac{d}{dp}(-\frac{1}{p^2}))$
$= p(1-p)(\frac{2}{p^3})$
$= (\frac{2(1-p)}{p^2})$
$= (\frac{2q}{p^2})$
A: Let A be the event that the first trial of the geometric distribution is a success: 
$P(A) = p$  
$P({A^c})=1-p$
Then 
$E({X^2} |A)= 1 $ and 
$E({X^2}|{A^c}) = E({(X+1)^2})$ since the first trial has already been counted as a failure. 
then 
$E({X^2}) = E({X^2}|A)P(A) + E({(X+1)^2}|{A^c})P({A^c})$
$ E({X^2})=1p + E({X^2} +2X +1)P({A^c})$
$E({X^2})=1p + (E({X^2}) + 2E(X) + 1)(1-p)$
You know $E(X)=1/p$ so you can just solve for $E({X^2})$ 
($(2-p)/{p^2}$)
A: A geometric distribution has probability mass function (pmf):
$$P(X=n)=p(1-p)^n$$
Now:
$$E(X)=\sum^\infty_n nP(X=n)$$
$$E(X^2)=\sum^\infty_n n^2P(X=n)$$
So for the geometric distribution:
$$E(X^2)=\sum^\infty_n n^2p(1-p)^n$$
$$E(X^2)=p\sum^\infty_n n^2(1-p)^n$$
$$E(X^2)=p\left(\frac{p^2-3 p+2}{p^3}\right)$$
$$E(X^2)=\frac{p^2-3 p+2}{p^2}$$
A: As suggested in the OP, we calculate $E(X(X-1))$.
There are two closely related versions of the geometric. In one of them, we count the number of trials until the first success. So the possible values are $1,2,3,\dots$. In the other version, one counts the number of failures until the first success. We use the first version. Minor modification will deal with the second.
Thus $\Pr(X=k)=p(1-p)^{k-1}$, and 
$$E(X(X-1))=\sum_{k=2}^\infty pk(k-1)(1-p)^{k-1}.$$
Consider the function 
$$f(t)=\frac{p}{1-t}=p(1+t+t^2+t^3+t^4+t^5+\cdots).$$
Note that
$$f''(t)=p((2)(1)+(3)(2)t+(4)(3)t^2+(5)(4)t^3+\cdots),$$
and therefore
$$tf''(t)=p((2)(1)t+(3)(2)t^2+(4)(3)t^3+(5)(4)t^4+\cdots).$$ 
Finally, set $t=1-p$, and note that $f''(t)=\frac{2p}{(1-t)^3}$.
A: If you know the variance of the geometric distribution, you can retrieve $E[X^2]$ from there:
$var(X) = E[X^2]-E[X]^2 => E[X^2]=var(X)+E[X]^2 = \frac{1-p}{p^2}+(\frac{1}{p})^2 = \frac{2-p}{p^2}$
