Correlation between Poisson and conditionally binomial random variables 
Let $X \sim \operatorname{Pois}(\lambda)$ and $Y \mid X=x \sim \operatorname{Bin}(x,p)$. Find $\operatorname{Cor}(X,Y)$.

The crucial step in the computation is to find $E(XY)$, which a I did using brute force calculation via the joint PMF and, alternatively, using iterated expecation. I found $E(XY) = pE(X)=p(\lambda^2+\lambda)$ and $\operatorname{Cor}(X,Y) = \sqrt{p}$.
I specifically would like to know if there is an approach using indicator random variables to compute $E(XY)$.
 A: 
Key-tool: Using indicator functions, one can rewrite every sum on some random set of indices as a sum on a fixed set, possible infinite.

Let $(U_n)$ denote an i.i.d. sequence of Bernoulli random variables independent of $X$ such that $P(U_n=1)=p$ and $P(U_n=0)=1-p$, then $Y$ can be constructed as $$Y=\sum_{n=1}^XU_n\color{red}{=}\sum_{n=1}^\infty U_n\mathbf 1_{X\geqslant n},$$ The $\color{red}{=}$ sign above is where we used the so-called key-tool stated at the beginning of our post. Now, by independence, $$E(XY)=\sum_{n=1}^\infty E(U_n)E(X\mathbf 1_{X\geqslant n})=p\sum_{n=1}^\infty E(X\mathbf 1_{X\geqslant n}).$$ Note that $$\sum_{n=1}^\infty\mathbf 1_{X\geqslant n}=X,$$ hence $$\sum_{n=1}^\infty E(X\mathbf 1_{X\geqslant n})=E(X^2),$$ and finally, in full generality, $$E(XY)=pE(X^2).$$
A: $X\sim\operatorname{Poisson}(\lambda)$ and $Y\mid X\sim\operatorname{Binomial}(X,p)$ and $Z=X-Y$ then


*

*$Y\sim\operatorname{Poisson}(\lambda p)$ and

*$Z\sim\operatorname{Poisson}(\lambda(1-p))$ and

*(a crucial point) $Y, Z$ are independent.
So $\operatorname{cov}(X,Y) = \operatorname{cov}(Y+Z,Y) = \operatorname{cov}(Y,Y)+\operatorname{cov}(Z,Y) = \operatorname{cov}(Y,Y)+0$.
The rest should be routine.
A: Given $X= x$, $Y$ is binomial with parameters $x$ and $p$, which means
$E[Y\mid X=x] = px$, i.e. $E[Y\mid X] = p X$.  Thus $E[XY] = E[X E[Y\mid X]] = p E[X^2]$. 
