Law of total covariance


In probability theory, the law of total covariance, covariance decomposition formula, or conditional covariance formula 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" or use other names.
and E are random variables whose values depend on the value of Z. Note that the conditional expected value of X given the event Z = z is a function of z. If we write E = g then the random variable E is g

Proof

The law of total covariance can be proved using the law of total expectation: First,
from a simple standard identity on covariances. 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 and E: