Finding covariance for the joint density function $f(y_1, y_2) = 3 y_1$ with $0 \leq y_2 \leq y_1 \leq 1$ and $0$ otherwise The problem asks to find the covariance. The joint density function is defined as,
$$
  f(y_1,y_2)=
  \begin{cases}
    3y_1, & \text{for $0 \leq y_2 \leq y_1 \leq 1$}, \\
       0, & \text{elsewhere}. \\
  \end{cases}
$$
My text defines
$$
    \operatorname{Cov}(Y_1,Y_2)
  = \mathbb{E}(Y_1 Y_2) - \mathbb{E}(Y_1)\mathbb{E}(Y_2).
$$
I'm having problems finding $\mathbb{E}(Y_2)$. My attempt is
\begin{gather*}
  \mathbb{E}(Y_2) = \int_{-\infty}^\infty y_2 f_2(y_2) \,\mathrm{d}y_2,
  \\
  f_2(y_2) = \int_{-\infty}^\infty f(y_1,y_2) \,\mathrm{d}y_1
           = \int_0^1 3y_1 \,\mathrm{d}y_1 = \frac{3}{2},
  \\
  \mathbb{E}(Y_2) = \int_0^1 y_2 \frac{3}{2} \,\mathrm{d}y_2
                  = \frac{3}{4}.
\end{gather*}
But my book says $\mathbb{E}(Y_2)= 3/8$. Where did I go wrong?
 A: Pay attention when you evaluate the marginal distribution of $Y_2$. Observe that
$$0 \leq y_2 \leq y_1 \leq 1.$$
Therefore, since you are integrating $y_1$ to get the marginal of $Y_2$, then the integration must be done on the set $y_2 \leq y_1 \leq 1$, not on $0 \leq y_1 \leq 1.$ In this case:
$$f_2(y_2)=\int_{-\infty}^{\infty} f(y_1,y_2) dy_1
         =\int_{y_2}^{1}3y_1dy_1=\frac{3}{2}(1-y_2^2),$$
valid for $0 \leq y_2 \leq 1.$
Then, the expected value of $Y_2$ is:
.
$$\mathbb{E}(Y_2)=\int_{0}^{1}  y_2 \frac{3}{2}(1-y_2^2)dy_2=\dfrac{3}{8}.$$
Same reasonings hold for the marginal of $Y_1$. In this case, you should consider $0 \leq y_2 \leq y_1.$
A: To find $E(Y_2)$ you should use a double integral since the density function has two variables.
\begin{eqnarray*}
E(Y_2) &=& \int_{0}^{1} \int_{0}^{y_1} 3 y_1 y_2 \,\, dy_2 dy_1 \\
E(Y_2) &=& \int_{0}^{1} \frac{ 3 y_1 y_2^2}{2} \Bigg|_{y_2=0}^{y_2=y_1} \,\, dy_1 =
\int_0^1 \frac{3y_1^3}{2} \,\, dy_1 \\
E(Y_2) &=& \frac{3y_1^4}{8} \Big|_0^1 \\
E(Y_2) &=& \frac{3}{8}
\end{eqnarray*}
I hope this helps. Feel free to ask a follow up question.
Bob
A: $$
f_{Y_2}(y_2) = \int_{y_2}^1 3y_1\, dy_1. \text{ This should not be } \int_0^1.
$$
The main error here appears to be trying to solve math problems by proceeding algorithmically rather than by understanding. The educational system in effect encourages that, and professors have their heads buried deep in the sand about that issue.
