Given the joint density of $X$ and $Y$,

$$f_{X,Y}(x,y)=\begin{cases}e^{-y}&\text{for }0\le x<y<\infty\\0&\text{otherwise}\end{cases},$$

(a) find the covariance and correlation of $X$ and $Y$;

(b) find $E[X\mid Y=y]$ and $E[Y\mid X=x]$; and

(c) find $E[X]$ and $\mathrm{Var}[X]$.

I know that


$$\mathrm{Corr}[X,Y]=\frac{\mathrm{Cov}[X,Y]}{\sqrt{\mathrm{Var}[X]\mathrm{Var}[Y]}},\text{ and}$$

$$E[XY]=\int_0^\infty\int_0^yxye^{-y}\,\mathrm dx\,\mathrm dy=3,$$

so theoretically, I should be able to compute the covariance by first finding the marginal densities for $X$ and $Y$, then computing the expectations of $X$ and $Y$. Alternatively, since

$$E[X]=E[E[X\mid Y=y]],$$

I can accomplish the same thing by finding the conditional densities and their expectations.

However, the ordering of the questions has me wondering:

(1) Can I compute the covariance and correlation directly knowing just the joint PDF?

As for finding the (necessary?) expectations, I've run into a complication...

The marginal density for $Y$ is

$$f_Y(y)=\int_0^ye^{-y}\,\mathrm dx=xe^{-y}\bigg|_0^y=\begin{cases}ye^{-y}&\text{for }y\ge0\\0&\text{otherwise}\end{cases}$$

so the conditional density of $X$ given $Y=y$ is

$$f_{X\mid Y}(x\mid y)=\begin{cases}\frac{e^{-y}}{ye^{-y}}=\frac1y&\text{for }0\le x<y<\infty\\0&\text{otherwise}\end{cases}$$

Then the conditional expectation of $X$ given $Y=y$ is

$$E[X\mid Y=y]=\int_0^y\frac xy\,\mathrm dx=\frac{x^2}{2y}\bigg|_0^y=\frac y2$$

and so

$$\boxed{E[X]=E[E[X\mid Y=y]]=E\left[\frac y2\right]=\frac y2}$$

Similarly, the marginal density for $X$ is

$$f_X(x)=\int_x^\infty e^{-y}\,\mathrm dy=-e^{-y}\bigg|_x^\infty=\begin{cases}e^{-x}&\text{for }x\ge0\\0&\text{otherwise}\end{cases}$$

so the conditional density of $Y$ given $X=x$ is

$$f_{Y\mid X}(y\mid x)=\begin{cases}\frac{e^{-y}}{e^{-x}}=e^{x-y}&\text{for }0\le x<y<\infty\\0&\text{otherwise}\end{cases}$$

and the expectation of $Y$ given $X=x$ would be

$$E[Y\mid X=x]=\int_x^\infty ye^{x-y}\,\mathrm dy=-(y+1)e^{x-y}\bigg|_x^\infty=x+1$$

and so the expectation of $Y$ is

$$\boxed{E[Y]=E[E[Y\mid X=x]]=E[x+1]=x+1}$$

The complication is that I get different expectations for $X$ and $Y$ when trying to verify their values using the corresponding marginal densities:

$$\boxed{E[X]=\int_0^\infty xe^{-x}\,\mathrm dx=1\\E[Y]=\int_0^\infty y^2e^{-y}\,\mathrm dy=2}$$

I thought that perhaps the problem lies with the supports of $f_X$ and $f_Y$. We have $0\le x<y<\infty$ to start with, so the marginal densities could instead be

$$f_X(x)=\begin{cases}e^{-x}&\text{for }0\le x<y\\0&\text{otherwise}\end{cases}$$

$$f_Y(y)=\begin{cases}ye^{-y}&\text{for }x\le y\\0&\text{otherwise}\end{cases}$$

But even then,

$$\boxed{E[X]=\int_0^yxe^{-x}\,\mathrm dx=1-(y+1)e^{-y}\neq\frac y2\\E[Y]=\int_x^\infty y^2e^{-y}\,\mathrm dy=(x^2+2x+2)e^{-x}\neq x+1}$$

(2) Which expectations are correct? Why the discrepancy between methods?

  • $\begingroup$ The correct formula is $E[X]=E[E[X\mid Y]]$, which gives a real number. Now $E[X\mid Y=y]$ is a function of $y$, say $g(y)$, so that $E[X\mid Y]=g(Y)$ is a random variable. $\endgroup$ Nov 21, 2019 at 19:54
  • $\begingroup$ I think part of your confusion is that the tower property of conditional expectation is $\mathbb E[X] = \mathbb E[\mathbb E[X\mid Y]]$, not $\mathbb E[X] = \mathbb E[\mathbb E[X\mid Y=y]]$. Consider that $\mathbb E[X\mid Y]$ is a random variable while $\mathbb E[X\mid Y=y]$ is a number. $\endgroup$
    – Math1000
    Nov 21, 2019 at 19:54
  • $\begingroup$ Recall also that for a random variable $X$, the quantity $\mathbb E[X]$ is a number, not a function. $\endgroup$
    – Math1000
    Nov 21, 2019 at 19:56
  • $\begingroup$ You can calculate any moment from the joint pdf alone, since $E[g(X,Y]=\iint g(x,y)f_{X,Y}(x,y)\,dx\,dy$ for any measurable function $g$. $\endgroup$ Nov 21, 2019 at 20:01
  • 1
    $\begingroup$ Okay, I see that I've been conflating $E[X\mid Y=y]$ (a number) with $E[X\mid Y]$ (a random variable). Is it true that $E[X\mid Y=y]=\frac y2$ means $E[X\mid Y]=\frac Y2$, and $E[Y\mid X=x]=x+1$ means $E[Y\mid X]=X+1$? If so, that would make finding $E[X]$ and $E[Y]$ really easy, and the resulting expectations do align with this assumption. $\endgroup$
    – user170231
    Nov 21, 2019 at 20:26

1 Answer 1


Thanks in large part to the commenters for getting me back on the right track. Posting the key points of my solution here for completeness.

$$E[XY]=\int_0^\infty\int_0^yxye^{-y}\,\mathrm dx\,\mathrm dy=3$$

$$E[X]=\int_0^\infty\int_0^yxe^{-y}\,\mathrm dx\,\mathrm dy=1$$

$$E[Y]=\int_0^\infty\int_0^yye^{-y}\,\mathrm dx\,\mathrm dy=2$$

$$E[X^2]=\int_0^\infty\int_0^yx^2e^{-y}\,\mathrm dx\,\mathrm dy=2$$

$$E[Y^2]=\int_0^\infty\int_0^yy^2e^{-y}\,\mathrm dx\,\mathrm dy=6$$



$$\boxed{E[X\mid Y=y]=\int_0^y\frac xy\,\mathrm dx=\frac y2}$$

$$\boxed{E[Y\mid X=x]=\int_x^\infty y^2e^{x-y}\,\mathrm dy=x+1}$$

$$\begin{cases} E[X]=E[E[X\mid Y]]=E\left[\frac Y2\right]=\frac{E[Y]}2\\[1ex] E[Y]=E[E[Y\mid X]]=E[X+1]=E[X]+1 \end{cases}\implies\boxed{E[X]=1}$$

$$E[X^2\mid Y=y]=\int_0^y\frac{x^2}y\,\mathrm dx=\frac{y^2}3$$

$$\mathrm{Var}[X\mid Y]=E[X^2\mid Y]-E[X\mid Y]^2=\frac{Y^2}3-\left(\frac Y2\right)^2=\frac{Y^2}{12}$$

$$E[\mathrm{Var}[X\mid Y]]=E\left[\frac{Y^2}{12}\right]=\frac{E[Y^2]}{12}=\frac12$$

$$\mathrm{Var}[E[X\mid Y]]=\mathrm{Var}\left[\frac Y2\right]=\frac{\mathrm{Var}[Y]}4=\frac{E[Y^2]-E[Y]}4=\frac12$$

$$\boxed{\mathrm{Var}[X]=E[\mathrm{Var}[X\mid Y]]+\mathrm{Var}[E[X\mid Y]]=1}$$


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .