I have the joint pdf $f_{X,Y}(x,y) =12(y-x)^2$ for $0<x<y<1$, and I'm tasked to find $C(X,Y)$. I understand that i can find $C(X,Y)$ by using
- $\int_{-\infty}^{\infty}\int_{-\infty}^{\infty}(x-E(X))(y-E(Y))f_{X,Y}(x,y)dxdy,$
but I can't seem to figure the limits of the integral. They way I see it, it should be x from 0 to y, and y from x to 1, but that gives me a function, not a value. And going from 0 to 1 in both cases does not make sense to me.
What am I missing here?
Perhaps the question is not worded clearly. More explicitly, the author means that the joint PDF is
$$ f(x,y)=12\left(y-x\right)^{2}[0<x<y<1] $$
where $[\cdot]$ is the Iverson bracket. Therefore
\begin{align*} \mathbb{E}[g(X,Y)] & =\int_{-\infty}^{\infty}\int_{-\infty}^{\infty}f(x,y)g(x,y)dydx\\ & =12\int_{0}^{1}\int_{x}^{1}\left(y-x\right)^2g(x,y)dydx. \end{align*}
You can verify that taking $g(x,y) = 1$ in the above integral yields 1 (as it should, since $f$ is a density).
Since $\operatorname{Cov}(X,Y)=\mathbb{E}[XY]-\mathbb{E}X\mathbb{E}Y$, you can arrive at the desired result by computing three integrals: one with $g(x,y)=xy$, one with $g(x,y)=x$, and one with $g(x,y)=y$ (for the last two, you can alternatively first marginalize out the corresponding variable to create marginal densities $f_X(x)$ and $f_Y(y)$).