How to calculate: $\sum_{n=1}^{\infty} n a^n$ I've tried to calculate this sum:
$$\sum_{n=1}^{\infty} n a^n$$
The point of this is to try to work out the "mean" term in an exponentially decaying average.
I've done the following:
$$\text{let }x = \sum_{n=1}^{\infty} n a^n$$
$$x = a + a \sum_{n=1}^{\infty} (n+1) a^n$$
$$x = a + a (\sum_{n=1}^{\infty} n a^n + \sum_{n=1}^{\infty} a^n)$$
$$x = a + a (x + \sum_{n=1}^{\infty} a^n)$$
$$x = a + ax + a\sum_{n=1}^{\infty} a^n$$
$$(1-a)x = a + a\sum_{n=1}^{\infty} a^n$$
Lets try to work out the $\sum_{n=1}^{\infty} a^n$ part:
$$let y = \sum_{n=1}^{\infty} a^n$$
$$y = a + a \sum_{n=1}^{\infty} a^n$$
$$y = a + ay$$
$$y - ay = a$$
$$y(1-a) = a$$
$$y = a/(1-a)$$
Substitute y back in:
$$(1-a)x = a + a*(a/(1-a))$$
$$(1-a)^2 x = a(1-a) + a^2$$
$$(1-a)^2 x = a - a^2 + a^2$$
$$(1-a)^2 x = a$$
$$x = a/(1-a)^2$$
Is this right, and if so is there a shorter way?
Edit:
To actually calculate the "mean" term of a exponential moving average we need to keep in mind that terms are weighted at the level of $(1-a)$. i.e. for $a=1$ there is no decay, for $a=0$ only the most recent term counts.
So the above result we need to multiply by $(1-a)$ to get the result:
Exponential moving average "mean term" = $a/(1-a)$
This gives the results, for $a=0$, the mean term is the "0th term" (none other are used) whereas for $a=0.5$ the mean term is the "1st term" (i.e. after the current term).

We give a mean proof, at least for the case $0\lt a\lt 1$. Suppose that we toss a coin that has probability $a$ of landing heads, and probability $1-a$ of landing heads. Let $X$ be the number of tosses until the first tail. Then $X=1$ with probability $1-a$, $X=2$ with probability $a(1-a)$, $X=3$ with probability $a^2(1-a)$, and so on. Thus
$$E(X)=(1-a)+2a(1-a)+3a^2(1-a)+4a^3(1-a)\cdots.\tag{$1$}$$
Note that by a standard convergence test, $E(X)$ is finite.
Let $b=E(X)$. On the first toss, we get a tail with probability $1-a$. In that case, $X=1$. If on the first toss we get a head, it has been a "wasted" toss, and the expected number of tosses until the first tail is $1+b$. Thus
$$b=(1-a)(1)+a(1+b).$$
Solve for $b$. We get $b=\dfrac{1}{1-a}$.
But the desired sum $a+2a^2+3a^3+\cdots$ is $\dfrac{a}{1-a}$ times the sum in $(1)$. Thus the desired sum is $\dfrac{a}{(1-a)^2}$.
