The expectation of a discrete random variable $X$ where $P(X=n)=\left(\frac12\right)^n$ The problem is:
Find the expectation of a discrete random variable $X$ whose probability function is given by $$P(X=n)=\left(\frac12\right)^n$$
($n=1,2,3,4,5,\dots$)
 A: $$\mathbb E[X]=\sum_{n=1}^\infty n\cdot\mathbb P[x=n]=\sum_{n=1}^\infty\frac{n}{2^n}$$
Now this here is just an arithmetico-geometric series, whose sum can be calculated with the following manipulations:
$$S=\sum_{n=1}^\infty\frac{n}{2^n}$$
$$2S=2\sum_{n=1}^\infty\frac{n}{2^n}=\sum_{n=1}^\infty\frac{n}{2^{n-1}}=\sum_{n=0}^\infty\frac{n+1}{2^n}=1+\sum_{n=1}^\infty\frac{n+1}{2^n}$$
$$2S-S=1+\sum_{n=1}^\infty\frac{n+1}{2^n}-\sum_{n=1}^\infty\frac{n}{2^n}=1+\sum_{n=1}^\infty\frac1{2^n}$$
Now $\sum_{n=1}^\infty\frac1{2^n}$ is just a geometric series, whose sum is $1$, so $S=\mathbb E[X]=1+1=2$.
A: Hint:
If $$f\left(x\right)=x+x^{2}+x^{3}+\cdots=\frac{x}{1-x}$$ then $$xf'\left(x\right)=x+2x^{2}+3x^{3}+\cdots$$
What do you recognize if you substitute $x=\frac12$?
A: For $\;|x|<1\;$ we have
$$\frac1{1-x}=\sum_{k=0}^\infty x^k\implies\frac1{(1-x)^2}\stackrel *=\sum_{k=1}^\infty kx^{k-1}$$
Now, by definition:
$$E(X):=\sum_{n=0}^\infty n\cdot P(X=n)=\sum_{n=0}^\infty n\left(\frac12\right)^n=\frac12\sum_{n=1}^\infty n\left(\frac12\right)^{n-1}\stackrel *=\frac12\frac1{\left(1-\frac12\right)^2}=2$$
