Skip to content
Glacius
ProbabilityConcept reference

Total expectation

The law of total expectation recovers an overall mean by weighting conditional means according to how often their cases occur.

On this page 7 sections
  1. Overview
  2. Average the group averages
  3. Unequal groups need unequal weights
  4. Reconstruct the joint weights
  5. Key takeaway
  6. Sources & further reading
  7. Concept connections

01Average the group averages#

The law of total expectation recovers an overall mean by weighting conditional means according to how often their cases occur. The cases form a complete, disjoint partition of the population.

Let μy=E[XY=y]\mu_y=E[X\mid Y=y] be the mean in case yy. Weight each mean by its case probability:

E[X]=yP(Y=y)μy\begin{gathered}E[X]\\=\sum_y P(Y=y)\mu_y\end{gathered}

One average happens inside each case. The outer average then combines the cases. Equal case weights represent an equally likely mixture. For unequal probabilities, use the actual weights even when equal averaging happens to give the same result.

02Unequal groups need unequal weights#

Suppose cases a,ba,b occur with probabilities 0.8,0.20.8,0.2, and their conditional means are 1,61,6. Their contributions to the overall mean are 0.80.8 and 1.21.2.

0.8(1)+0.2(6)=2.0.8(1)+0.2(6)=2.

The unweighted average of the group means is 3.53.5, which describes a different mixture. Small high-loss groups can matter greatly, but their contribution still uses their probability.

Check your reasoning

Case probabilities are (0.75,0.25); conditional means are (2,10). Find the overall mean.

  1. A4
  2. B6
  3. C3
Show answer and explanation
4

The outer weighted average is 1.5+2.5=4.

03Reconstruct the joint weights#

Substitute each conditional mean's weighted sum into the rule. A value xx in case yy receives weight P(y)P(xy)=P(x,y)P(y)P(x\mid y)=P(x,y). Summing across cases recovers its marginal probability P(x)P(x) and hence the original expectation.

Check your reasoning

80% of cases have mean 0 and 20% have mean 10. A draft reports overall mean 5. Repair it.

  1. A5
  2. B2
  3. C8
Show answer and explanation
2

The correct mixture uses weights 0.8 and 0.2.

In ML, averaging performance separately across groups is not enough to obtain a target population's expected loss. You also need that population's group proportions. Changing the proportions can change the overall mean even when every within-group mean stays fixed.

Key takeaway

Recover an unconditional mean by averaging conditional means.

  • Recover an unconditional mean by averaging conditional means.

Sources & further reading

  1. [1]
  2. [2]
    Harvard Stat 110, Strategic Practice 10 (2011)stat110.hsites.harvard.edu · Article
  3. [3]

Reference this concept

Link to this page, a section, or an individual figure.

Glacius. “Total expectation.” Math behind ML. /learn/p-total-expectation