# Moment generating function

• Dec 6th 2009, 05:29 PM
xuyuan
Moment generating function
I'm trying to work out a practice problem but it seems like the way I'm doing it is so off track.

The goal is to find u'2 or the second moment generating function evaluated at t=0 for the random variable x with probability density

x/2 for 0<x<2
0 elsewhere

I started with 1/2*int(x*e^(tx),x, 0, 2)
(integrate x from 0 to 2) using the integration by parts I get this long integration of

.5[1/t*e^(tx)-1/t[1/te^(tx)]

Is the way I'm doing it even right up until this part? If it isn't how should I be doing it, and if it is, do I just take the derivative twice here with respect to t?

More generally, I think my question and confusion lies with this: If the probability density is given to be continuous like the one above but only from say 0 to 2 or 1 to infinity. Am I still integrating e^(tx)f(x) from 0 to infinity when I try to find the mgf? or am I only integrating from the defined 0 to 2 or 1 to infinity?

thanks a lot to anyone who can make this subject just a little simpler for me!
• Dec 6th 2009, 05:40 PM
mr fantastic
Quote:

Originally Posted by xuyuan
I'm trying to work out a practice problem but it seems like the way I'm doing it is so off track.

The goal is to find u'2 or the second moment generating function evaluated at t=0 for the random variable x with probability density

x/2 for 0<x<2
0 elsewhere

I started with 1/2*int(x*e^(tx),x, 0, 2)
(integrate x from 0 to 2) using the integration by parts I get this long integration of

.5[1/t*e^(tx)-1/t[1/te^(tx)]

Is the way I'm doing it even right up until this part? If it isn't how should I be doing it, and if it is, do I just take the derivative twice here with respect to t?

More generally, I think my question and confusion lies with this: If the probability density is given to be continuous like the one above but only from say 0 to 2 or 1 to infinity. Am I still integrating e^(tx)f(x) from 0 to infinity when I try to find the mgf? or am I only integrating from the defined 0 to 2 or 1 to infinity?

thanks a lot to anyone who can make this subject just a little simpler for me!

By definition, $\displaystyle m(t) = E(e^{tX}) = \int_\Omega e^{tx} f(x) \, dx$ where $\displaystyle \Omega$ is the support of the pdf.

I haven't checked your calculation (the formatting is too difficult to decipher) but your method is correct. Once you have found $\displaystyle m(t)$ you need to calculate $\displaystyle \frac{d^2m}{dt^2}$ and then evaluate this at t = 0.
• Dec 6th 2009, 05:42 PM
Chris L T521
Quote:

Originally Posted by xuyuan
I'm trying to work out a practice problem but it seems like the way I'm doing it is so off track.

The goal is to find u'2 or the second moment generating function evaluated at t=0 for the random variable x with probability density

x/2 for 0<x<2
0 elsewhere

I started with 1/2*int(x*e^(tx),x, 0, 2)
(integrate x from 0 to 2) using the integration by parts I get this long integration of

.5[1/t*e^(tx)-1/t[1/te^(tx)]

Is the way I'm doing it even right up until this part? If it isn't how should I be doing it, and if it is, do I just take the derivative twice here with respect to t?

More generally, I think my question and confusion lies with this: If the probability density is given to be continuous like the one above but only from say 0 to 2 or 1 to infinity. Am I still integrating e^(tx)f(x) from 0 to infinity when I try to find the mgf? or am I only integrating from the defined 0 to 2 or 1 to infinity?

thanks a lot to anyone who can make this subject just a little simpler for me!

In general, to find the mgf of a pdf, you evaluate $\displaystyle \int_{-\infty}^{\infty}e^{tx}f\!\left(x\right)\,dx$.

Becaue your pdf is defined as a piecewise function, notice that when we integrate $\displaystyle \tfrac{1}{2}xe^{tx}$, the bounds become 0 to 2.

So, $\displaystyle \int_{-\infty}^{\infty} e^{tx}f\!\left(x\right)\,dx=\tfrac{1}{2}\int_0^2 xe^{tx}\,dx$.

Integration by parts yields $\displaystyle \tfrac{1}{2}\left.\left[\frac{xe^{tx}}{t}-\frac{e^{tx}}{t^2}\right]\right|_0^2=\frac{e^{2t}}{t}-\frac{e^{2t}}{2t^2}+\frac{1}{2t^2}$

Can you take it from here and find the second moment?
• Dec 6th 2009, 06:48 PM
xuyuan
Quote:

Originally Posted by Chris L T521
In general, to find the mgf of a pdf, you evaluate $\displaystyle \int_{-\infty}^{\infty}e^{tx}f\!\left(x\right)\,dx$.

Becaue your pdf is defined as a piecewise function, notice that when we integrate $\displaystyle \tfrac{1}{2}xe^{tx}$, the bounds become 0 to 2.

So, $\displaystyle \int_{-\infty}^{\infty} e^{tx}f\!\left(x\right)\,dx=\tfrac{1}{2}\int_0^2 xe^{tx}\,dx$.

Integration by parts yields $\displaystyle \tfrac{1}{2}\left.\left[\frac{xe^{tx}}{t}-\frac{e^{tx}}{t^2}\right]\right|_0^2=\frac{e^{2t}}{t}-\frac{e^{2t}}{2t^2}+\frac{1}{2t^2}$

Can you take it from here and find the second moment?

yes, thank you very much! This does wonders to solve a lot of the confusion I was having about the proper way to evaluate mgfs if the function's not defined as x>0. Now that I think about it, it makes so much sense, sense a lot of the problems were defined as x>0 so I've been integrating from 0 to infinity, it should make sense that it just carries through when its something like x>1

Edit: Follow up question should the X always disappear after finding the mgf? There's no way that you can get an mgf where the X still exists right? Otherwise you wouldn't be able to evaluate the derviatives of the mgfs at t?
• Dec 7th 2009, 11:37 AM
xuyuan
Follow up question should the X always disappear after finding the mgf? There's no way that you can get an mgf where the X still exists right? Otherwise you wouldn't be able to evaluate the derviatives of the mgfs at t?
• Dec 7th 2009, 09:29 PM
matheagle
Quote:

Originally Posted by xuyuan
Follow up question should the X always disappear after finding the mgf? There's no way that you can get an mgf where the X still exists right? Otherwise you wouldn't be able to evaluate the derviatives of the mgfs at t?

It's $\displaystyle M_X(t)=E(e^{Xt})$
It's a function of t.
But it's the moment generating function of the random variable X.
The expectation is wrt X, so the x is integrated/summed out, leaving this a function of the argument t.