# What is the moment generating function given a density of a continuous random variable?

Let $X$ be a continuous random variable with a density $$f_X(x) = \begin{cases}e^{-(x-1)}& \text{for }x > 1\\ 0 & \text{otherwise}\end{cases}$$ How do I compute the moment generating function of X? What is the range on which the moment generating function is defined?

How do I used the moment generating function to compute the mean, the second moment and the variance of X?

-

As noted above (and standard anyway) $M(t)=E(e^{tx})=\int_1^{oo} e^{tx}e^{-(x-1)} dx$. Note that if t=1 the integrand becomes simply e^1, and the integral does not exist. So M(1) is undefined. Also note that if $t>1$ the integrand is $e^{(t-1)x+1}>e^{(t-1)x}$ which since $t>1$ goes to infinity as $x$ does. So M(t) does not exist for t>1.

We claim now that M(t) exists for t<1. The antiderivative of the integrand is $\frac {e^{-x(1-t)}e^1}{t-1}$, which goes to $0$ as $x$ approaches infinity, and evaluates to $\frac {e^t}{t-1}$ at $x=1$. We thus have the formula

$M(t)=\frac {e^t}{1-t}$

for the moment generating function, on the domain $\{t:t<1\}$. Note that this domain includes an open neighborhood of 0, so that moment generating calculations of moments can be done as usual.

To get the mean, second moment, and variance we only need a few terms of the series for $M(t)$. We can get these by multiplying the series for $e^t$ by the series for $1/(1-t)$. That is,

$(1+t+t^2/2+t^3/6+...)(1+t+t^2+t^3+...)$

which gives first few terms $M(t)=1+2t+(5/2)t^2+(8/3)t^3+...$. Then the usual procedure of taking derivatives and putting in zero gives $E(X)=2$ and $E(X^2)=5$. Finally, using the standard formula for variance we get $V(X)=E(X^2)-[E(X)]^2=5-2^2=1$.

-
If my series for $M(t)$ is right, first derivative is $2+5t+...$ and plugging in 0 gives 2 for $M'(0)$. You can say that $M(0)=1$ from my series, but that just means $E(X^0)=1$, true for any random variable. – coffeemath Oct 10 '12 at 19:33
You can also calculate the moments directly, by integrating power of $x$ times pdf. I just did this on maple and got the same answers, $E(X)=2$ and $E(X^2)=5$. This could also be done by hand, using integration by parts. – coffeemath Oct 10 '12 at 19:47

The moment generating function is $$M_X(t) = E[e^{tX}] = \int_1^\infty e^{tx} e^{-(x-1)}\ dx$$ Hint: in order for this improper integral to be defined, you want to check what happens as $x \to \infty$.

-
As $x \to \infty$, $M_x(t) \to 0$? – idealistikz Oct 10 '12 at 6:13
$x$ is the dummy variable in the integration defining $M_X(t)$. The question is, for what values of $t$ does that integral converge? – Robert Israel Oct 10 '12 at 6:36
The integral converges when $t=0$. Can we assume $t<1$? – idealistikz Oct 10 '12 at 6:41
I don't understand because as $x \to \infty$, $M_x(t) \to \infty$ if $t>1$. What am I missing? – idealistikz Oct 10 '12 at 6:44
There is no such thing as $M_x(t)$. If $t > 1$, $e^{tx} e^{-x-1} \to \infty$ as $x \to \infty$, and then the integral diverges. Also if $t=1$, the integral diverges. – Robert Israel Oct 10 '12 at 18:24

MGF is defined as $M_X(t)=E(e^{tX})$.

Calculation of moments can be done through $E(X^n)=\frac{d^n M_X}{dt^n}(0)$.

-