Skip to content
Free public beta until December 4, 2026: every course is open, no card needed. After that, the first chapter of each course stays free and full access is a one-time $39 ($19 for up to 100 founding members chosen for helpful feedback). Your progress is kept. How the beta works

Recipe

Compute a conditional expectation

Use when: you need E(Y\mid X=x) and have (or can build) the joint distribution of X and Y

Goal: a single number: Y's average value, restricted to the world where X=x

Taught in Conditional expectation

  1. 1

    Before any averaging can happen, you need the distribution to average.

    Example

    Using the commute table above, condition on no rain instead of rain. The no-rain row is 0.06 (late) and 0.74 (on time), totaling 0.80. Dividing each cell by that row total: P(\text{late}\mid\text{no rain}) = \frac{0.06}{0.80} = 0.075, \qquad P(\text{on time}\mid\text{no rain}) = \frac{0.74}{0.80} = 0.925

    • the joint table is given — divide the row (or column) matching X=x by that row's own total, turning it back into a distribution that sums to 1.
    • the conditional distribution is already handed to you directly — skip straight to Step 2.

    Why: E(Y\mid X=x) is defined as a weighted average against this exact narrowed distribution, so the distribution has to exist first.

  2. 2

    Multiply each possible value of Y by its own conditional probability and add the results. This is an ordinary weighted average, computed against the narrowed distribution from Step 1 instead of Y's plain marginal.

    Example

    Continuing with no rain, and coding late as 1 and on-time as 0: E(\text{late-code}\mid\text{no rain}) = 1(0.075) + 0(0.925) = 0.075

    Why: this sum is exactly the definition E(Y\mid X=x)=\sum_y y\cdot p_{Y\mid X}(y\mid x), run against whichever distribution Step 1 produced.

  3. 3

    Recall (or compute) the plain unconditional E(Y), and compare which subpopulation each number actually describes.

    Example

    The unconditional probability of being late is 0.12+0.06=0.18, well above the 0.075 found above: conditioning on no rain pulls the average DOWN, since lateness is rarer on dry days.

    Why: a conditional mean that happens to equal the unconditional mean is itself informative, it signals the conditioning variable carries no information about Y at all.

Common mistakes

  • Dividing by the wrong marginal, using the column total when conditioning on a row (or vice versa).
  • Forgetting to renormalize, and treating the raw joint-table cells as though they already summed to 1.
  • Averaging against the marginal distribution by accident instead of the conditional one built in Step 1.
  • Reporting the conditional probabilities from Step 1 as the final answer, without ever actually running the weighted average in Step 2.