# Thread: negative variance... (getting correlation from joint density)

1. ## negative variance... (getting correlation from joint density)

Question. Consider random variables X and Y with joint density

$f(x)=\left\{\begin{array}{cc}8xy,&\mbox{ if }
0

Evaluate Corr (X,Y).

To use Corr (X,Y) formula, I will need to know Cov(X,Y)=E(XY)-E(X)E(Y) and Var(X) and Var(Y). This is a simple question but I keep getting negative variance for X and I re-checked several times. Help!!

$f_X(x)=\int^{\infty}_{-\infty}f_{X,Y}(x,y)dy=\int^1_x8xydy=8x[\frac{y^2}{2}]^1_x=8x(\frac{1}{2}-\frac{x^2}{2})=4x(x-x^2)=4x-x^3$ (on the interval 0<x<1, and 0 otherwise)

$E(X)=\int^{\infty}_{-\infty}xf_{X}(x)dx=\int_0^1x(4x-x^3)dx=\int_0^1(4x^2-x^4)dx=$
$=[\frac{4x^3}{4}-\frac{x^5}{5}]_0^1=4/3-1/5=17/15$

$E(X^2)=\int^{\infty}_{-\infty}x^2f_{X}(x)dx=\int_0^1x^2(4x-x^3)dx=$
$=\int_0^1(4x^3-x^5)dx=$
$=[4x^4/4-x^6/6]_0^1=1-1/6=5/6$

Then $Var(X)=E(X^2)-E(X)^2=5/6-(17/15)^2=-203/450 <0$

(For Y, $f_Y(y)=4y^3$ and Var(Y)=2/75, so I should be able to proceed to find Cov and Corr if I have a positive result for Var(X)).

thanks!

2. You fudged up calculating $f_X (x)$. It should be $4(x - x^3) \mbox{I}_{x \in [0, 1]}$.

Also, IMO, calculating the marginal of X is just asking for a stupid mistake. Calculate all the expectations from the joint, and integrate over x first so that you don't have the additive terms. It doesn't matter for the end result, but its easier and you can do it in your head.

3. Looks like another Walpole problem
I wouldn't get the marginals.
You should integrate all expectations using...

$\int_0^1\int_0^y ....dxdy$

or you can use

$\int_0^1\int_x^1 ....dydx$

But I prefer 0 as the lower bounds.

4. Or dear, I must be the worst mathematician on this forum )))

Thanks for the tip, this makes sense, dealing with one integrand instead of three different ones.

5. Well I teach out of Walpole and I also teach multivariate calc.
IF you decide to get the marginals, then you are forcing yourself to integrate in a particular order.
What is smarter, is to figure out which was is best, dxdy or dydx, and then integrate all of these
expectations in that order.

6. Yes, I see your point. I did study multivariable calc a couple of months ago.

Here, I followed the approach given in my Study Guide (from London School of Economics, Distribution Theory by J. Penzer) - I self-study, ie no access to lectures or tutorials. Now I consulted the texbook (I use Hogg and Tanis, and also Grimmet and Stirzaker) and they have the same alternative too.

I find this forum helps enormously in my situation, thank you all!