Let $X \sim \operatorname{Exp}(\lambda).$ Find $E[X^n]$, for all $n \in N$. Let $X \sim \operatorname{Exp}(\lambda).$
Find $E[X^n]$, for all $n \in N$.
I'm having difficulty figuring out how to do this problem and not sure quite how to solve this. I know that I'm supposed to apply the exponential distribution here, but still can't figure this out. Thanks in advance.
 A: The moment generating function of a random variable $X$ is defined by
$$  M_X(t) = E(e^{tX}) =
\begin{cases}
\sum_i e^{tx_i}p_X(x_i),  & \text{(discrete case)} \\
\\
\int_{-\infty}^{\infty} e^{tx}f_X(x)dx, & \text{(continuous case)}
\end{cases}
$$
If we express $e^{tX}$ formally and take expectation
$$M_X(t) = E(e^{tX}) = 1 + tE(X) + \frac{t^2}{2!}E(X^2)+ \ldots +
\frac{t^n}{n!}E(X^n)+ \ldots$$
Hence the $n$th moment of $X$ is given by
$$E(X^n) = M_X^{(n)}(0) \:\:\:\:\:\:n = 1, 2 \ldots$$
$$M_X^{(n)}(0) = \frac{d^n}{dt^n} M_X(t) |_{t=0}$$
A: Write $I_n = E[X^n]$. You have
$$ I_n = \int_{-\infty}^{\infty} x^n \cdot f_X(x) \, dx $$
where $f_X$ is the probability density function of $X$. In your case,
$$ I_n = \int_0^{\infty} x^n \cdot (\lambda e^{-\lambda x}) \, dx. $$
Applying integration by parts with $u = x^n$ and $dv = \lambda e^{- \lambda x} \, dx$ (so $v = -e^{- \lambda x}$), you have
$$ I_n = \int_0^{\infty} u \, dv = [-x^n e^{-\lambda x}]^{x = \infty}_{x = 0} - \int_{0}^{\infty} v \, du = n \int_0^{\infty} x^{n-1} e^{-\lambda x} \, dx = \frac{n}{\lambda}I_{n-1}.$$
This is a recursion for $I_n$ whose solution is $I_n = \frac{n!}{\lambda^n} \cdot I_0 = \frac{n!}{\lambda^{n}}$ (as $I_0 = 1$ since $f_X$ is a probability density function).
