# Thread: Find the MGF of a random variable given its pdf

1. ## Find the MGF of a random variable given its pdf

Note: This forms part of an assignment I'm on the hook for, so I'm really looking for pointers on where I'm going wrong as opposed to just a 'here's your answer' reply

The Problem: we have a random variable with a known probability density function:

f(x) = c*x^2, for (0 <= x <= 1), f(x) is 0 otherwise.

I can find c, and subsequently determine the Expected Value (E(X)) of the r.v. using moments approach (ie: integrating for (x*f(x)) to find E(X) in this case). *BUT* to verify my result, I'm trying to determine the Moment Generating Function (MGF) for the given distribution & then solve for the 1st moment. I'm expecting to get the same result for E(X) as obtained above but instead I'm getting a mess.

I'm doing this by hand at the moment so it could be I've just borked my arithmetic.

Questions:
1) I'm assuming I can, in this particular case, determine the MGF and that it'll derive the moments I need for me. Is that sane?
2) The MGF I get (through an iterative process of integrating by parts on the back of a piece of paper): (Mx(t)= 6*(e^t - 1)/t^3 - 6*e^t/t^2 + 3*e^t/t )

I'm sure my result for (2) is incorrect, or I'm completely missing something, since obviously the first moment isn't solvable (dM/dt for t=0 blows up), thus I can't verify the mean is the same value as I calculated originally above.

Expert help gratefully appreciated

2. ## Re: Find the MGF of a random variable given its pdf

your mgf is incorrect.. try calculating it again..

after you find the value of c, integrate $\int_0^1 e^{tx} f(x)\; dx$ to find your mgf..

3. ## Re: Find the MGF of a random variable given its pdf

Thanks for the quick reply harish21.

Yep so that's the integral I've solved to produce my original answer in (2). Here's a breakdown of my approach. Can you identify specifically where I've gone wrong with my simple calculus?:

My value for c is 3, achieved purely through integrating f(x) over the interval 0 to 1, knowing that integral's value is 1.

the MGF integral is thus : $\inline \int_{0}^{1}e^{tx}3x^{2}dx$

(edit: borked my latex in the original post to show incorrect parts)
So I break this down by parts, 1st iteration using:
$\inline \newline u=3x^{2} \newline du=6xdx \newline dv = e^{tx}dx \newline v = \frac{e^{tx}}{t}$

I can see at this point things are already going south since I'm left with 't' as the denominator:

$\newline \frac{3x^{2}.e^{tx}}{t} - \frac{6}{t}\int x.e^{tx}dx$

(edit: borked my latex in the original post to show incorrect parts)
Breakdown by parts, 2nd iteration using:
$\inline \newline u=x \newline du=dx \newline dv = e^{tx}dx \newline v = \frac{e^{tx}}{t}$

& solving the integral over the interval x = (0,1), gives my MGF:

$\frac{6\left ( e^{t}- \right 1)}{t^{3}} - \frac{6e^{t}}{t^{2}} + \frac{3e^{t}}{t}$

4. ## Re: Find the MGF of a random variable given its pdf

sorry for making you work again.. actually the mgf you had mentioned first was corrrect indeed.. the non-latex notation confused me..
so you have your mgf.. now to find the expected value.. find out the first derivative of your mgf at t=0.. that should give you your expected value.

5. ## Re: Find the MGF of a random variable given its pdf

no dramas, it's all helping to test my rusty understanding of this.

"find out the first derivative of your mgf at t=0"
...& that's where I come undone - if I try to derive the 1st moment of my mgf (ie: $\inline \newline \frac{dM_{x}(t)}{dt}|_{t=0}$) I'm sunk on account of the t in the denominator of the derivative forcing a divide-by-zero exception.

Here's my attempt at the 1st derivative, again just simple calc. exploiting the product rule. Looks sane to you?

$\inline \newline \frac{dM_{x}(t)}{dt} = \frac{18(1-e^{t})}{t^{4}} + \frac{18e^{t}}{t^{3}} - \frac{9e^{t}}{t^{2}} + \frac{3e^{t}}{t}$

If I now try to take the value of that function at t=0, thus to obtain to the 1st moment, I can't.

Assuming the approach is valid, I'm overlooking or misunderstanding something as I can't see a way around my prob. ie: why I can get E(x) using the $\int x.f(x)dx$ approach (per my original post), but cannot verify it using the MGF above.

6. ## Re: Find the MGF of a random variable given its pdf

so the mgf is $\dfrac{18-18e^t+18te^t-18t^2e^t+3e^tt^3}{t^4}$ which is of the form 0/0 at t=0

take $\lim_{t \to 0} \dfrac{18-18e^t+18te^t-18t^2e^t+3e^tt^3}{t^4}$

using L'Hopital's rule correctly should give you 3/4

,

,

,

,

,

,

,

,

,

,

,

,

,

,

# given pdf find the mgf mx(t)mx(t) of xx.

Click on a term to search for related topics.