Let $X$ and $Y$ be jointly distributed random variables such that $Y|X=x \in Bin(n,x)$ with $X \in U(0,1)$. We must find $E(Y)$, $Var(Y)$ and $Cov(X,Y)$.
I was able to complete the first two tasks, but I ran into trouble on the co-variance.
I used the fact: $ Cov(X,Y) = E[ (Y-E(Y))(X-E(X)) ] = E(XY) - E(X)E(Y) $
I know $E(Y) = \frac{n}{2}$ and $E(X) = \frac{1}{2}$ so the second term must be $\frac{n}{4}$. I know the answer is $\frac{n}{12}$ so the first term must come out to be $\frac{n}{3}$. I've tried many eclectic strategies, but nothing worked.
Thank you for your input!
Using law of total expectation, \begin{align} E[XY] &= E[E[XY|X]] \\ &= E[XE[Y|X]] \\ &= E[X(nX)] \\ &= n E[X^2] \\ &= n \int_0^1 x^2 dx \\ &=\frac{n}{3} \end{align}