[Math] how can I find E(XY) using the moment generating function

calculusmoment-generating-functionsprobabilityprobability theory

Let $X,Y$ a random variable with density $f(x,y)=\frac{2}{5}(2x+3y),\quad 0<x<1, 0<y<1$.

Find the joint moment generating function.

I find that the answer is:

$$M_{XY}(t_1,t_2)={4\over5}(\frac{e^{t_1}}{t_1}-\frac{e^{t_1}-1}{t_1^2})(\frac{e^{t_2}-1}{t_2})+{6\over5}(\frac{e^{t_2}}{t_2}-\frac{e^{t_2}-1}{t_2^2})(\frac{e^{t_1}-1}{t_1})$$

I want to know if it is correct

Best Answer

Let's do it.

$$M_{XY}(t_1,t_2)=E[e^{t_1 X + t_2Y }]=\int \int e^{t_1 x}e^{t_2 y } \frac{2}{5}(2x+3y) dx dy$$

It's too hot here in the south, I'll use Maxima:

f(x,y):=(2*x+3*y)*(2/5);

ratsimp(
 (4/5)*(%e^t1/t1-(%e^t1-1)/t1^2)*((%e^t2-1)/t2)  + 
 (6/5)*(%e^t2/t2-(%e^t2-1)/t2^2)*((%e^t1-1)/t1)  -
 integrate(integrate(f(x,y) *exp(t1*x)*exp(t2*y), x, 0, 1),y,0,1)
);

0

So it's ok.

The title also asks about computing $E(XY)$ from the $M_{XY}$

You can do that by applying $$\frac{\partial^2 M_{XY}(t_1,t_2)}{\partial t_1 \partial t_2} \biggr\rvert_{t_1=0,t_2=0}=E(XY)$$

but 1) you must be sure that you are allowed to do that (the MGF is well behaved around zero) 2) you might consider it too cumbersome

In this case, it might appear that 1) does not apply - the MGF seems to blow up at zero, but that's not so, there is an indeterminancy that we can resolve by Taylor expansion. Because $e^x=1+x+x^2/2 +x^3/6+O(x^4)$ we have:

$$\frac{e^{x}-1}{x}=1+\frac{1}{2}x+O(x^2)$$

and

$$\frac{e^{x}}{x}-\frac{e^{x}-1}{x^2}=\frac{x+x^2+x^3/2- (x+x^2/2+x^3/6) + O(x^4)}{x^2}=\frac{1}{2}+\frac{1}{3}x+O(x^2)$$

Then, disregarding $O(x^2)$ terms:

$$ M_{XY}(t_1,t_2) = \frac{4}{5}(\frac{1}{2}+\frac{1}{3}t_1)(1+\frac{1}{2}t_2)+ \frac{6}{5}(\frac{1}{2}+\frac{1}{3}t_2)(1+\frac{1}{2}t_1) + O(t_1^2)O(t_2^2) $$

(to check: $M_{XY}(0,0)=1$)

Can you follow on from here? I get $E(XY)=1/3$

(Of course, it would have been easier to compute $E(XY)$ directly by integration, but I guess that's not the point).