Loading lesson…
Courses›Conditioning Zooms the Leftover

Conditioning Zooms the Leftover

DetailedOverviewQuizFlashcard

Conditioning Zooms the Leftover

Conditioning Zooms the Leftover

Scenario that fails

A junior engineer looks at a spam filter's inbox and reports: "only 16% of the emails that contain free are spam, so the free rule is not worth keeping." She computed

850=0.16\frac{8}{50} = 0.16

and proposed dropping the rule. The 16% is real arithmetic on the wrong denominator. The question this lesson answers is short: which emails should she have counted? The answer is the strip of emails the word free actually kept, not the whole inbox.

Grid of 50 emails with 20 spam and a 10-email strip containing free.

Before the zoom: 8 of the 50 tiles are both free and spam (0.16 of the inbox). [ILLUSTRATION]

Conditioning zooms the leftover — zoom into the strip and re-read it as a budget of 1.

The inbox as a rectangle of leftover

Use one secondary inbox for the whole page: 50 emails, 20 spam, 10 contain free, 8 are both. The same numbers appear in the figures, the lab, the quiz and the flashcards.

QuantityValue
P(spam∣free)=8/10P(\text{spam}\mid\text{free}) = 8/100.8 (home)
P(free∩spam)=8/50P(\text{free}\cap\text{spam}) = 8/500.16 (wrong-denominator answer)
P(free∣spam)=8/20P(\text{free}\mid\text{spam}) = 8/200.4 (swapped answer)
P(free)=10/50P(\text{free}) = 10/500.2
P(spam)=20/50P(\text{spam}) = 20/500.4

The inbox is a rectangle of 50 tiles. Spam is a set of tiles inside it; free is a strip of 10 tiles. Eight tiles sit in both. Nothing about those eight tiles changes when we learn the word free — what changes is which tiles we are still allowed to count.

The zoom

Learn "this email contains free". Every tile outside the free strip is now impossible. It does not become zero spam or zero ham; it leaves the picture. The strip of 10 tiles fills the screen and becomes the whole world.

Zooming does not create or destroy emails. It hides the ones you have ruled out and stretches the strip to fill the screen. The fraction you then read is the conditional. The wrong-denominator error is reading the zoomed fraction while still counting the hidden tiles.

The free strip enlarged; 8 of its 10 tiles are spam.

Zoom into free and re-read the strip as a whole budget: 8/10 = 0.8. [ILLUSTRATION]

Re-read the strip as a budget of 1

Inside the strip there are 10 emails: 8 spam and 2 ham. The conditional re-reads that strip as a new budget:

P(spam∣free)=810=0.8P(\text{spam}\mid\text{free}) = \frac{8}{10} = 0.8

The 2 ham emails are the leftover inside the zoom: 0.20.2. And

0.8+0.2=10.8 + 0.2 = 1

Lesson 1's budget rule survives the zoom. Conditioning is not a second universe with a new total; it is the same tiles, with a new denominator.

The formula, derived

The counting form divides the overlap by the strip:

P(B∣A)=n(A∩B)n(A)=810=0.8P(B\mid A) = \frac{n(A\cap B)}{n(A)} = \frac{8}{10} = 0.8

Divide the top and the bottom by the inbox size N=50N = 50:

P(B∣A)=n(A∩B)/Nn(A)/N=P(A∩B)P(A)=0.160.2=0.8P(B\mid A) = \frac{n(A\cap B)/N}{n(A)/N} = \frac{P(A\cap B)}{P(A)} = \frac{0.16}{0.2} = 0.8

Show both lines. The first is the picture: count the strip. The second is what survives when there are no counts, only masses. The mass form is the one that will still work when the inbox size is unknown.

Why the strip must have mass

The mass form divides by P(A)P(A), so it needs P(A)>0P(A) > 0. In the picture, if no email contained free, there would be no strip to outline and nothing to re-read. A conditional on an empty strip is undefined, not zero: zero would claim the strip exists and contains no spam.

The zoomed budget still sums to 1

Split the zoomed strip into spam and ham:

P(B∣A)+P(Bc∣A)=P(A∩B)+P(A∩Bc)P(A)=P(A)P(A)=1P(B\mid A) + P(B^c\mid A) = \frac{P(A\cap B) + P(A\cap B^c)}{P(A)} = \frac{P(A)}{P(A)} = 1

For the home inbox: 0.8+0.2=10.8 + 0.2 = 1. The zoom changes the denominator, never the total.

Multiplication rule, read backwards

The same three numbers, rearranged, give the joint mass:

P(A∩B)=P(A) P(B∣A)=0.2×0.8=0.16P(A\cap B) = P(A)\,P(B\mid A) = 0.2 \times 0.8 = 0.16

That is the 0.16 from the report. It is a real quantity — P(free and spam)P(\text{free and spam}) — but it is not P(spam∣free)P(\text{spam}\mid\text{free}). Lesson 8 uses the four-tile table this line comes from.

A one-line preview of total probability

The whole spam mass can be rebuilt from the two strips:

P(spam)=P(spam∣free)P(free)+P(spam∣no free)P(no free)=0.8(0.2)+1240(0.8)=0.16+0.24=0.4P(\text{spam}) = P(\text{spam}\mid\text{free})P(\text{free}) + P(\text{spam}\mid\text{no free})P(\text{no free}) = 0.8(0.2) + \frac{12}{40}(0.8) = 0.16 + 0.24 = 0.4

This line is only a preview: Lesson 3 reallocates the leftover from the other direction. On this page it is a check that the strips still add up to the 20 spam tiles.

Back to the 16% report

The engineer's 0.16 is P(free and spam)P(\text{free and spam}), the eight tiles divided by all fifty. The conditional divides those same eight tiles by the ten emails the zoom kept:

810=0.8\frac{8}{10} = 0.8

So the report's arithmetic is right and its sentence is wrong. "Only 16% of free emails are spam" should read "80% of free emails are spam; 16% of all emails are both free and spam." Dropping the free rule is a decision about 0.8, not about 0.16.

The other zoom gives a different number

Zoom into spam instead. Now the strip is the 20 spam emails, and 8 of them contain free:

P(free∣spam)=820=0.4P(\text{free}\mid\text{spam}) = \frac{8}{20} = 0.4

Same eight emails, different strip, different denominator. This is the swap, and it is also Lesson 10's home value. Say the strip out loud before dividing: "I am inside free" gives 8/10; "I am inside spam" gives 8/20.

Two zooms of the same overlap giving 0.8 and 0.4.

Same 8 emails, two different strips, two different conditionals. [ILLUSTRATION]

Worked examples

Home: 8/10=0.88/10 = 0.8. Mass form: 0.16/0.2=0.80.16/0.2 = 0.8. The strip's leftover is 0.20.2, and 0.8+0.2=10.8 + 0.2 = 1.

Wrong paths as numbers: divide by the inbox → 8/50=0.168/50 = 0.16; zoom into the wrong strip → 8/20=0.48/20 = 0.4; condition on an empty strip → undefined (not 0, not NaN).

Transfer: 25 emails contain meeting, and 5 of those are spam.

P(spam∣meeting)=525=0.2P(\text{spam}\mid\text{meeting}) = \frac{5}{25} = 0.2

Follow-up: if the inbox has 100 emails, what does the wrong-denominator answer give? It gives 5/100=0.055/100 = 0.05, the joint mass divided by the whole inbox, not the conditional.

Code that prints the numbers

nA, nAB, N, nB = 10, 8, 50, 20
print(nAB / nA)                # 0.8   zoom into the 10 free emails
print(nAB / N)                 # 0.16  wrong denominator: whole inbox
print(nAB / nB)                # 0.4   swapped zoom: into 20 spam
print((nAB / N) / (nA / N))    # 0.8   mass form: 0.16 / 0.2

Interactive lab

Three controls: the size of the strip n(A)n(A), the overlap n(A∩B)n(A\cap B), and the fail toggle "divide by the whole inbox (the mistake)". Reset returns to 10 / 8 / off and reads 0.8. Set n(A)=0n(A) = 0 and the lab prints the undefined sentence instead of 0 or NaN.

Interactive lab loads with the lesson app.

Failure modes

  1. Swapping P(A∣B)P(A\mid B) and P(B∣A)P(B\mid A). Spot it when the answer is 0.4 for the home question. Fix: say the strip out loud before dividing.
  2. Dividing by the wrong leftover. Spot it when the answer is 0.16. Fix: the hidden tiles do not count after the zoom; 0.16 is the joint mass.
  3. Conditioning on a zero-probability strip. Spot it when the answer is "0". Fix: undefined, because there is no budget to re-read.
  4. "Conditioning is a different universe." Fix: it is the same tiles; the zoomed budget still sums to 1.

Honesty table

ClaimTag
Home 8/10=0.88/10 = 0.8 and the secondary inbox 50 / 20 / 10 / 8REAL — numpy prove (docs/probability/setup/prove-home-numbers.py) and runProbL2
Junior engineer's 16% reportILLUSTRATION — teaching failure, not a product screenshot
Stills prob_l2_inbox_grid, prob_l2_zoom, prob_l2_two_zoomsILLUSTRATION — teaching diagrams on Worker CDN (HTTP 200 verified)
AI hook: supervised learning models P(y∣x)P(y\mid x)PUBLISHED — standard supervised-learning framing; not proved on this page

| Lesson video | shipped | Worker mp4 + cover (about 208.7 s walk) |

Video

The lesson plate above is the narrated walk of the conditioning-zooms-the-leftover lesson: the wrong-denominator 0.16 report, the 50-email inbox, the zoom into free (8/10 = 0.8), the mass form 0.16/0.2, the spam-side swap 0.4, the empty-strip undefined case, and the P(y|x) hook. It is served from the SuperLearn media Worker; there is no second copy in the app bundle.

Sources

Rewrite, never paste: Bertsekas & Tsitsiklis 2e §1.3 (conditional probability) and §1.4 (total probability); Piech, Probability for Computer Scientists, Part 1; Blitzstein Ch. 2; Goodfellow §3.5.

Next: Bayes turns the 0.4 back into 0.8 when you only know the spam-side numbers (Lesson 3).