# Finding the first and second moments from mgf and finding general formula for nth moment

Suppose that the random variable Y has the moment generating function:

$M_y(t) = \frac{1}{5}(e^{-2t} + e^{-t} + 1 + e^t + e^{2t})$

for all real t.

1) Find $E[Y]$ and $VAR[Y]$.

2) Give a general formula for calculating $E[Y^n]$ for all n.

For problem 1, I took the derivative of the mgf and set t=$0$ and got $E[Y] = 0$ and then I took the second derivative and got $VAR[Y] = 2$.

Then for problem 2, I tried taking the derivative a couple more times and what I got was:

$M_{y^n}(t) = \frac{1}{5}((-1)^n2n + (-1)^n + 1 + 2n)$. This seemed to work whenever $t=0$ but I may be wrong. Any insight is greatly appreciated.

-
You mean $M^{(n)}(0)=\dots$. And it is $2^n$, not $2n$ (both places). This is $0$ for $n$ odd, more complicated when $n$ is even. – André Nicolas Nov 19 '12 at 21:44

Compute the successive derivatives of $e^{2t}$. We get $2e^{2t}, 4e^{2t}, 8e^{2t}$, and so on. The $n$-th derivative is $2^ne^{2t}$.
Similarly, the $n$-th derivative of $e^{-2t}$ is $(-2)^ne^{-2t}$, which perhaps looks better as $(-1)^n2^ne^{-2t}$. Thus the $n$-th derivative $M^{(n)}(t)$ of the moment generating function is given by $$M^{(n)}(t)=\frac{1}{5}\left((-1)^n 2^n e^{-2t} +(-1)^ne^{-t}+e^t+2^n e^{2t}\right).$$ Evaluating at $0$, we get $$M^{(n)}(0)=\frac{1}{5}\left((-1)^n 2^n +(-1)^n+1+2^n\right).$$ Note that the $n$-th derivative at $0$ is $0$ for all odd $n$. For even $n$, it is $\dfrac{2}{5}(2^n+1)$.