# Probability Question - Moment Generating Function

$$f(x) = \begin{cases} xe^{-x}, & \text{x ≥ 0} \\ 0, & \text{elsewhere} \end{cases}$$

Q: Find the Moment Generating Function of X.

Hi, I was trying to solve this question by putting the equation as

$$\int_{0}^\infty e^{tx}xe^{-x}dx$$ but then I couldn't get it. Any help or suggestions would be appreciated! Thanks.

• You could try integrating by parts. Additionally keep in mind that the moment-generating function is just the Laplace transform (up to a minus sign in the exponential), so all of the tricks for it work as well. en.wikipedia.org/wiki/Laplace_transform – Chill2Macht Apr 26 '16 at 21:53

If you accept the fact that $f(x)$ as described is a legitimate probability density function, then we can state that $$\int_{x=0}^\infty x e^{-x} \, dx = 1.$$ From this, we observe $$M_X(t) = \operatorname{E}[e^{tX}] = \int_{x=0}^\infty e^{tx} x e^{-x} \, dx = \int_{x=0}^\infty x e^{-(1-t)x} \, dx.$$ Now with the variable substitution $$u = (1-t)x, \quad du = (1-t) \, dx,$$ we obtain $$M_X(t) = \int_{u=0}^\infty \frac{u}{1-t} e^{-u} \cdot \frac{1}{1-t} \, du = \frac{1}{(1-t)^2} \int_{u=0}^\infty ue^{-u} \, du = \frac{1}{(1-t)^2},$$ provided that $t < 1$. If $t \ge 1$, then the integral fails to converge, as is evident by the fact that $e^{-(1-t)x} \ge 1$ if $x > 0$ and $t \ge 1$. Note in the last step, we used the assumption that $f$ is a density.
This method of using the fact that the total probability of a random variable equals $1$ over its support, is very useful for computing expectations of functions of random variables. It is also worth noting that $f$ is a gamma distribution with shape parameter $a = 2$ and rate parameter $b = 1$, and is a special case of the gamma PDF $$f_X(x) = \frac{b^a x^{a-1} e^{-bx}}{\Gamma(a)}, \quad x > 0, \quad a,b > 0.$$ It is an instructive exercise to apply this method to obtain the MGF of the gamma distribution for the general parametric case (you may assume that the density so defined above integrates to $1$ over $(0,\infty)$).
Integrating by parts $$\int_0^\infty e^{(t-1) x} x \mathrm dx =\left.\frac{x e^{(t-1) x}}{t-1}\right|_0^\infty-\frac{1}{t-1}\int_0^\infty e^{(t-1) x} x \mathrm dx=-\left.\frac{e^{(t-1) x}}{(t-1)^2}\right|_0^\infty=\frac{1}{(t-1)^2}\quad \text{for }t<1$$