# conditional expectation, covariance

Show 40 post(s) from this thread on one page
Page 1 of 2 12 Last
• Feb 1st 2011, 06:19 PM
Volga
conditional expectation, covariance
Question. Let X and Y be random variables with joint density

$\displaystyle f_{X,Y}(x,y)=\left\{\begin{array}{cc}{ke^{-{\lambda}x},0<y<x<{\infty}\\0, &otherwise\end{array}\right.$

Derive the conditional density, $\displaystyle f_{X|Y}(x|y)$, and the conditional expectation, E[X|Y]. Hence or otherwise, evaluate E(X) and Cov(X,Y).

(I highlighted the questions that came up along the answer write up by ->>>>>)

$\displaystyle f_Y(y)=\int_{-\infty}^{\infty}f_{X,Y}(x,y)dx=\int_y^{\infty}ke^{-{\lambda}x}dx=k\int_y^{\infty}e^{-{\lambda}x}dx=k[(-\frac{1}{\lambda}e^{-{\lambda}x}]_y^{\infty}=\frac{k}{\lambda}e^{-{\lambda}y}$,
$\displaystyle 0<y<{\infty}$.

->>>>>>>Is this support right, or should I say $\displaystyle 0<y<x<{\infty}$ (ie include x in it)

$\displaystyle f_{X|Y}(x|y)=\frac{f_{X,Y}(x|y)}{f_Y(y)}=\frac{ke^ {-{\lambda}x}}{\frac{k}{\lambda}e^{-{\lambda}y}}={\lambda}e^{\lambda(y-x)}$

Then expected value

$\displaystyle E(X|Y)=\int_{-infty}^{\infty}xf_{X|Y}(x|y)dx=\int_y^{\infty}x{\l ambda}e^{({\lambda}y-{\lambda}x)}dx={\lambda}e^{{\lambda}y}\int_y^{\inf ty}xe^{-{\lambda}x}dx=$
$\displaystyle ={\lambda}e^{{\lambda}y}\frac{e^{-{\lambda}y}}{\lambda}(y-1)=y-1$

($\displaystyle \int_y^{\infty}xe^{-{\lambda}x}=[x(-\frac{1}{\lambda}})e^{-{\lambda}x}]_y^{\infty}-\int_y^{\infty}e^{-{\lambda}x}dx=[\frac{-xe^{-{\lambda}x}}{\lambda}]_y^{\infty}-[-\frac{1}{\lambda}e^{-{\lambda}x}]_y^{\infty}=\frac{ye^{-{\lambda}y}}{\lambda}-\frac{e^{-{\lambda}y}}{\lambda}=\frac{e^{{-\lambda}y}}{\lambda}(y-1)$)

Therefore E(X|Y)=Y-1

"Hence" somehow hint on using E(X|Y) in evaluating E(X), and I try that:

$\displaystyle E(X)=E[E[X|Y]]=E[Y-1]=E(Y)-1$

->>>>>>So still need to do the integration to find E(X) directly from the integral, or E(Y) first and then deduct 1 to get E(X). Right?

I find E(Y) since the integration is slightly easier.

$\displaystyle \int_{-\infty}^{\infty}=\int_0^{\infty}y\frac{k}{\lambda} e^{-{\lambda}y}dy=\frac{k}{\lambda}\int_0^{\infty}ye^{-{\lambda}y}dy=-k$ but I probably messed up signs somewhere and I feel it should be k... (no big deal, I'll recheck).

->>>>>The question is, do I need to take into account the bound on y which is y<x?

Once I get E(Y), $\displaystyle E(X)=E(Y)-1=k-1$.

Then $\displaystyle Cov(X,Y)=E(XY)-E(X)E(Y)$ and again I need to integrate to find E(XY), right? Or there is an easy way...
• Feb 1st 2011, 08:47 PM
matheagle
The density of Y only depends on y.
But the conditional will have 0<y<x

You're missing the exponent in the first integration.
And you should compute k immediately.
you have lots of errors in your integration for E(X|Y) like the x.
• Feb 1st 2011, 10:06 PM
Volga
Yes, sorry - the first integration and the E(X|Y) calculation wasn't properly 'latex'ed, I have corrected. I also added more explanation to E(X|Y) (intermediate integration).
• Feb 1st 2011, 10:13 PM
matheagle
Logically I have a problem with E(X|Y)=Y-1.
IF X>Y, how can it's expectation be less than it's lower bound?
Again, you should solve for k immediately.
If you compute the double integral of f(x,y) and set it equal to 1, that should tell you what k is.
• Feb 1st 2011, 10:18 PM
Volga
I agree. I need to recompute $\displaystyle f_Y(y)$ because I took the bounds for x starting from y, not from 0 (ie as in conditional density bounds). So the y density is not right, therefore, the conditional x|y density above is not right.

Updated: No, I think I was right in the first calculation, x is bounded by y from below and therefore it belongs there in the calculation of $\displaystyle f_Y(y)$.

By the way, why do you say calculate k (why not lambda, for example)? Updated - see k calculation below.
• Feb 1st 2011, 10:21 PM
matheagle
sorry, it's almost 1:30 AM
I need sleep
• Feb 1st 2011, 10:33 PM
Volga
Calculation of k.

$\displaystyle \int_{x=0}^{\infty}\int_{y=0}^xke^{-{\lambda}x}dydx=\int_0^{\infty}ke^{-{\lambda}x}dx\int_0^xdy=\int_0^{\infty}ke^{-{\lambda}x}[y]_0^x=$

$\displaystyle =\int_0^{\infty}ke^{-{\lambda}x}xdx=k\int_0^{\infty}xe^{-{\lambda}x}dx=k([x(\frac{-1}{\lambda}e^{-{\lambda}x}]_0^{\infty}-\int_0^{\infty}\frac{-1}{\lambda}e^{-{\lambda}x}dx)=k([-\frac{x}{\lambda}e^{-{\lambda}x}]_0^{\infty}-\frac{1}{{\lambda}^2}[e^{-{\lambda}x}]_0^{\infty}=$

$\displaystyle =k(0-\frac{1}{{\lambda}^2}(0-e^0))=k\frac{1}{{\lambda}^2}=1$

therefore $\displaystyle k={\lambda}^2$
• Feb 1st 2011, 10:34 PM
Volga
Quote:

Originally Posted by matheagle
sorry, it's almost 1:30 AM
I need sleep

thanks, you've already helped a lot!
• Feb 2nd 2011, 03:13 PM
Volga
Umm... After rechecking,I am kind of at the same point, E(X|Y)=Y-1 and it still does not make sense.
• Feb 2nd 2011, 08:05 PM
matheagle
Fine, I'll look at it.
WE just had 20 inches of snow and my car is buried..........
The street won't be cleared for days nor my parking lot.
So clearing my car is not even the point.

$\displaystyle k=\lambda^2$ and there's no reason to do parts on that.
After the first integration you should let $\displaystyle u=\lambda x$ and use the gamma function.

Then $\displaystyle f_Y(y)=\lambda e^{-\lambda y}$ when y>0.

So Then $\displaystyle f(x|y)=\lambda e^{-\lambda (x-y)}$ when x>y>0.

My answer is $\displaystyle {1\over \lambda}+y$

By the way I did this in about 2 minutes, here's my work.
Watch how I do NOT integrate...

$\displaystyle E(X|Y=y)=\int_y^{\infty}x e^{-\lambda (x-y)} \lambda dx$

Let $\displaystyle u=\lambda (x-y)$ making $\displaystyle du=\lambda dx$

Thus $\displaystyle E(X|Y=y)=\int_0^{\infty}\left( {u\over\lambda}+y\right) e^{-u} du$

$\displaystyle = {1\over\lambda}\int_0^{\infty}ue^{-u} du +y\int_0^{\infty} e^{-u} du$

$\displaystyle = {1\over\lambda}\Gamma (2) +y\Gamma (1)$

$\displaystyle = {1\over\lambda}+y$

This answer makes sense, since it exceeds Y and it depends on lambda.
• Feb 2nd 2011, 08:46 PM
Volga
Well, what can I say, you are worth your name! I have never been friends with Gamma function, not since the calculus days. I will re-do the integration again, now that I know the right answer. Hope you recover your car. It's a glorious day here with +18C and sunny, and all I am jumping between distribution theory and linear algebra with no end in sight.
• Feb 3rd 2011, 08:14 AM
harish21
Quote:

Originally Posted by matheagle
Fine, I'll look at it.
WE just had 20 inches of snow and my car is buried..........
The street won't be cleared for days nor my parking lot.
So clearing my car is not even the point.

Are you in/from Chicago?
• Feb 3rd 2011, 08:43 AM
matheagle
unfortunately so
• Feb 4th 2011, 02:45 AM
Volga
Quote:

Originally Posted by matheagle
By the way I did this in about 2 minutes, here's my work.
Watch how I do NOT integrate...

$\displaystyle E(X|Y=y)=\int_y^{\infty}x e^{-\lambda (x-y)} \lambda dx$

Let $\displaystyle u=\lambda (x-y)$ making $\displaystyle du=\lambda dx$

Thus $\displaystyle E(X|Y=y)=\int_0^{\infty}\left( {u\over\lambda}+y\right) e^{-u} du$

$\displaystyle = {1\over\lambda}\int_0^{\infty}ue^{-u} du +y\int_0^{\infty} e^{-u} du$

$\displaystyle = {1\over\lambda}\Gamma (2) +y\Gamma (1)$

$\displaystyle = {1\over\lambda}+y$

This answer makes sense, since it exceeds Y and it depends on lambda.

This is neat, I think I can learn this trick. Just one question, when you substituted $\displaystyle y=u=\lambda (x-y)$ you didn't do anything to the lower bound of integral which was$\displaystyle y$ - instead, you put it zero. Is it legitimate? Since the lower bound was y, and the new variable of integration (u) still depends on y, why did you change it to zero just like that?

(Also, isn't it strange that $\displaystyle \Gamma(2)$ and $\displaystyle \Gamma(1)$ both equal to the same number, 1? understand that this comes from $\displaystyle \Gamma(n)=(n-1)!$ and that 0!=1 by convention, but I still find it very strange.)

By the way, I did another (non-Gamma) integration but with some substition and I got to $\displaystyle y-\frac{1}{\lambda}$ which is still not correct. But I'll rechecked my signs and I still cannot figure out where I make mistake. I'll keep trying, binomially, until success...
• Feb 4th 2011, 02:58 AM
Volga
Now, taking $\displaystyle E(X|Y)=y+\frac{1}{\lambda}$...

$\displaystyle E(X)=E[E(X|Y)]=E(Y+\frac{1}{\lambda})=E(Y)+\frac{1}{\lambda}$

now trying out the Gamma integral and setting $\displaystyle u={\lambda}y$, then $\displaystyle dy=\frac{du}{\lambda}$

$\displaystyle E(Y)=\int_0^{\infty}y\frac{k}{\lambda}e^{-{\lambda}y}dy=\frac{k}{\lambda}\int_0^{\infty}({\l ambda}y)e^{-{\lambda}y}\frac{1}{\lambda}dy=\frac{k}{\lambda}\i nt_0^{\infty}ue^{-u}du\frac{1}{{\lambda}^2}=\frac{k}{{\lambda}^3}\in t_0^{\infty}ue^{-u}du=\frac{k}{{\lambda}^3}{\Gamma}(2)=\frac{k}{{\l ambda}^3}=\frac{{\lambda}^2}{{\lambda}^3}=\frac{1} {\lambda}$

Does it make sense?

Then $\displaystyle E(X)=\frac{k}{{\lambda}^3}+\frac{1}{\lambda}=\frac {{\lambda}^2}{{\lambda}^3}+\frac{1}{\lambda}=\frac {2}{\lambda}$

To find Cov (X,Y), looks like I still need to integrate more, to find E(XY) or E(Y^2):

$\displaystyle Cov(X,Y)=E(XY)-E(X)E(Y)$
$\displaystyle E(XY)=E(YX)=E[E(YX|Y)]=E[YE(X|Y)]=E(Y(Y+\frac{1}{\lambda}))=E(Y^2)+\frac{1}{\lambda }E(Y)$

question - can I do that E(XY)=E(YX)?

then,

$\displaystyle E(Y^2)=\int_0^{\infty}y^2\frac{k}{\lambda}e^{-{\lambda}y}dy$ can be dealt with again using Gamma function (y^(3-1))

Thanks!!

Saw the Chicago snowstorm news on TV today. How do you guys move around? the roads are just full of snow, looks like nothing moves.
Show 40 post(s) from this thread on one page
Page 1 of 2 12 Last