What will be $E(X)$ and $Var(X)$? Given a discrete random variable
$$P(X = k) = \frac{1}{2^k}, \ \ \ k=1,2,...$$
How to calculate the expected value and Variance of $X$?
 A: Let $E(x)=\sum_{k=1}^\infty kx^k$ and $D(x)=\sum_k x^k$. Then
$$
E(x)+D(x)=\sum_k(k+1)x^k=\frac{d}{dx}\left(\sum_{k=1}^\infty x^{k+1}\right)=\frac{d}{dx}\frac{x^2}{1-x}=\frac{x(2-x)}{(1-x)^2}\cdot
$$
In particular,
$$
E(0.5)=\frac{0.5(2-0.5)}{(1-0.5)^2}-D(0.5)=3-1=2.
$$
This takes care of the expectation. Similarly, let $F(x)=\sum_{k=1}^\infty k^2x^k$. Then:
$$
F(x)+3E(x)+2D(x)=\sum_k(k+1)(k+2)x^k=\frac{d^2}{dx^2}\left(\sum_{k=1}^\infty x^{k+2}\right)=\frac{d^2}{dx^2}\frac{x^3}{1-x}=\frac{2x(-3+3x-x^2)}{(1-x)^3}.
$$
And so
$$
F(0.5)=\frac{2(0.5)(-3+1.5-0.5^2)}{(1-0.5)^3}-3E(0.5)-2D(0.5)=14-6-2=6.
$$
The variance is thus $6-2^2=2$.
A: Alternative method: Let $p(z)$ denote the probability generating function of $X.$ Then,
$$\begin{align*}
p(z) &= E[z^X] \\
&= \sum_{k=1}^{\infty} z^k P(X=k) \\
&= \sum_{k=0}^{\infty} \left( \frac{z}{2} \right)^k - 1\\
&= \frac{2}{2-z} - 1 \\
&= \frac{z}{2-z}
\end{align*}$$
So then since $p'(z) = 2/(2-z)^2$ and $p''(z)=4/(2-z)^3,$ we can calculate the expectation and variance as,
$$ E[X] = p'(1) = 2, $$
$$ Var(X) = p''(1) + p'(1) - (p'(1))^2 = 2. $$
A: By definition, $E(X) = \sum\frac{k}{2^k}$, this is not quite easy to compute, but you can use tail sum formula $E(X) = \sum P(X\ge i)$, to get $E(X) = 2$.
For variance, $Var(X) = E(X^2)-E(X)^2$, $E(X^2) = E(X(X+1))-E(X)$
$$E(X(X+1)) = \sum\frac{k(k+1)}{2^k} = 2^{2}\frac{d^2}{dx^2}\sum x^{-k}|_{x=2}$$$$ = 2^{2}\frac{d^2}{dx^2}(\frac{x}{x-1})|_{x=2}=2^{2}\cdot2(x-1)^{-3}|_{x=2} = 8$$
so $E(X^2) = 6$, $Var(X) = 2$.
The caluclation just interchange the order of summation and differentiation, for absolute convergence series this is legit. This is just a geometric distribution with $p = q = 1/2$, the variance can also be computed by conditioning, almost every textbook of Probability theory should contains it.
