Law of total covariance (source code)

= Law of total covariance
{title2=$\operatorname{Cov}(X,Y)=\mathbb E\operatorname{Cov}(X,Y\mid\Lambda)+\operatorname{Cov}(\mathbb E[X\mid\Lambda],\mathbb E[Y\mid\Lambda])$}
{wiki}

For square-integrable random variables, expand $X$ and $Y$ into their <conditional expectations> and their centered conditional residuals. The cross terms vanish by the <law of total expectation>, giving the displayed <covariance> decomposition. Conditional independence can therefore coexist with positive unconditional covariance from a shared <latent variable>.