I'm stuck with a question regarding conditional expectation.
If $X$ denotes the number of successes in n independent Bernoulli trials. Where the success probability is unknown and modelled by the random variable $Y$, $X | Y = y ~bin(n,y)$ and $Y$ is assumed uniformly distributed on $(0,1)$.
1) How do I use the conditional distribution $X|Y=y$ to find the expectation and the variance of $X$?
I know I somehow have yo use $E(X)= E(E(X|Y))$ and $Var(X)=E(Var(X|Y))+Var(E(X|Y))$, but I'm not sure where to start. Could someone give me a helping hand?
Since $X\mid Y=y$ is distributed like $\mathrm{bin}(n,y)$ for $y\in (0,1)$, we have ${\rm E}[X\mid Y=y]=ny$ for $y\in (0,1)$ or equivalently ${\rm E}[X\mid Y]=nY$. Thus $$ {\rm E}[X]={\rm E}[{\rm E}[X\mid Y]]=\ldots $$ Similarly, ${\rm Var}(X\mid Y=y)=ny(1-y)$ for $y\in (0,1)$ or equivalently ${\rm Var}(X\mid Y)=nY(1-Y)$ and hence $$ {\rm Var}(X)={\rm E}[{\rm Var}(X\mid Y)]+\mathrm{Var}({\rm E}[X\mid Y])=\ldots $$