[Math] the moment generating function from a density of a continuous random variable

moment-generating-functionsprobability

Let X be a random variable with probability density function $$f(x)=\begin{cases}xe^{-x} \quad \text{if } x>0\\0 \quad \text{ } Otherwise.\end{cases} $$
Determine the mgf of X whenever it exists.

I know that $M(t) = E(e^{tx}) =\int e^{tx}f(x)~dx$ but not sure what to do from there.

Thanks for the help.

Best Answer

We begin, as you indicated, with the integral $\int_{-\infty}^\infty e^{tx}f(x)dx$ In order to find this integral, we may proceed as follows:

$$ \int_{-\infty}^\infty e^{tx}f(x)dx = \int_0^\infty x e^{tx} e^{-x}dx =\int_0^\infty x e^{(t-1)x}dx $$ From there, use integration by parts. That is, we have $\int u\,dv = uv - \int v\, du$. For this problem, we choose $u = x$ and $dv = e^{(t-1)x}dx$. Applying the rule gives us $$ \begin{align} \int_0^\infty xe^{(t-1)x}dx &= \left[\frac{1}{t-1}x e^{(t-1)x}\right]_0^\infty - \int_0^\infty \frac{1}{t-1} e^{(t-1)x}dx\\ &= \frac{1}{t-1} \left[x e^{(t-1)x}\right]_0^\infty - \frac{1}{(t-1)^2}\left[e^{(t-1)x}\right]_0^\infty\\ &= \frac{1}{t-1} \cdot 0 - \frac{1}{(t-1)^2}\cdot (-1)\\ &= \frac{1}{(t-1)^2} \end{align} $$