I have X,Y as jointly distributed random variables such that $$ Y|X=x \in Bin(n,x) \ with \ X \in U(0,1) $$
I am trying to find $ Cov(X,Y)$. I found $$EX=\frac{1}{2}\qquad EY=\frac{n}{2},\qquad Var(Y)=\frac{n}{6}+\frac{n^2}{12} $$ but I am stuck with $Cov(X,Y)$.
I have something like this :
$$ cov(X,Y) = E(XY)-E(X)\cdot E(Y) \\ E(XY) = \int_{-\infty}^{+\infty}\int_{-\infty}^{+\infty} xy \cdot f_{XY}(x,y) dx dy = \int_{-\infty}^{+\infty}\int_{0}^{1}xy \cdot {n \choose k}x^k(1-x)^{n-k}dx \ dy $$
Is the above E(XY) - the only way to solve this? If yes - please help finish it since for me it is leading to huge expressions and being stuck.
$$\mathbb{E}[X^2]-\mathbb{E}[X]^2=Var(X)=\frac1{12}$$
$$\mathbb{E}[X^2]=\frac{1}{12}+\frac{1}{4}=\frac13$$
\begin{align}\mathbb{E}[XY]&=\mathbb{E}[\mathbb{E}[XY|X]]\\&=\mathbb{E}[X[\mathbb{E}[Y|X]]]\\&=\mathbb{E}[nX^2] \\&=\frac{n}{3}\end{align}