Law of total covariance
In probability theory, the law of total covariance,[1] covariance decomposition formula, or ECCE states that if X, Y, and Z are random variables on the same probability space, and the covariance of X and Y is finite, then
The nomenclature in this article's title parallels the phrase law of total variance. Some writers on probability call this the "conditional covariance formula"[2] or use other names.
(The conditional expected values E( X | Z ) and E( Y | Z ) are random variables in their own right, whose values depends on the value of Z. Notice that the conditional expected value of X given the event Z = z is a function of z (this is where adherence to the conventional rigidly case-sensitive notation of probability theory becomes important!). If we write E( X | Z = z) = g(z) then the random variable E( X | Z ) is just g(Z). Similar comments apply to the conditional covariance.)
Proof
The law of total covariance can be proved using the law of total expectation: First,
from the definition of covariance. Then we apply the law of total expectation by conditioning on the random variable Z:
Now we rewrite the term inside the first expectation using the definition of covariance:
Since expectation of a sum is the sum of expectations, we can regroup the terms:
Finally, we recognize the final two terms as the covariance of the conditional expectations E[X|Z] and E[Y|Z]:
Notes and references
See also
- Law of total variance, a special case corresponding to X = Y.

![\operatorname{cov}[X,Y] = \operatorname{E}[XY] - \operatorname{E}[X]\operatorname{E}[Y]](../I/m/8091b443b773e388f8982808f47136ce.png)
![= \operatorname{E}[\operatorname{E}[XY\mid Z]] - \operatorname{E}[\operatorname{E}[X\mid Z]]\operatorname{E}[\operatorname{E}[Y\mid Z]]](../I/m/811277580078ad2c738c2cb581fa7e16.png)
![= \operatorname{E}\!\left[\operatorname{cov}[X,Y\mid Z] + \operatorname{E}[X\mid Z]\operatorname{E}[Y\mid Z]\right] - \operatorname{E}[\operatorname{E}[X\mid Z]]\operatorname{E}[\operatorname{E}[Y\mid Z]]](../I/m/6d91f3d2ffce6481bcfcdc79eb89db8e.png)
![= \operatorname{E}\!\left[\operatorname{cov}[X,Y\mid Z]] + \operatorname{E}[\operatorname{E}[X\mid Z]\operatorname{E}[Y\mid Z]\right] - \operatorname{E}[\operatorname{E}[X\mid Z]]\operatorname{E}[\operatorname{E}[Y\mid Z]]](../I/m/eae2339317a056dd16a724a58bd99a93.png)
