Loading lesson…
Courses›Leftover Must Sum to 1

Leftover Must Sum to 1

DetailedOverviewQuizFlashcard

Leftover Must Sum to 1

Leftover Must Sum to 1

Scenario that fails

A spam filter's dashboard shows three numbers for one email: "spam 0.40, promo 0.35, personal 0.30". An engineer reads them as chances. They add to 1.05. Something is claiming money that does not exist.

Which number is wrong? The page answers that with a budget picture, not a definition.

Bar chart: 0.40, 0.35 and a teal leftover bar of 0.25 summing to 1; a dashed 0.30 bar marked as overspending.

Two masses fix the third: 1−0.40−0.35=0.251 - 0.40 - 0.35 = 0.25. A 0.30 bar would spend leftover that does not exist. [ILLUSTRATION]

Leftover must sum to 1 — a budget of exactly one; the leftover is forced.

Outcomes do not overlap

In this story one email gets exactly one label. Picture three bins; the email lands in one. The three numbers are not independent dials. They are pieces of the same whole.

The budget picture

One bar of length 1 is cut into pieces. Each piece is a mass. Lengths cannot be negative and cannot exceed the whole bar.

A strip from 0 to 1 split at 0.40 and 0.75; the last piece is the leftover.

One budget, three pieces, no gaps and no overlaps. [ILLUSTRATION]

Think of a pizza cut for a fixed table. A takes 0.40 of the pizza, B takes 0.35, and whatever is still on the tray (0.25) belongs to "everyone else". You cannot serve 1.05 pizzas, and no one can take a negative slice. A mass is a share of a budget for one uncertain outcome — not "percent of 100 people".

The leftover is forced

Once A and B are cut, the rest of the bar is fixed:

P(L)=1−P(A)−P(B)=1−0.40−0.35=0.25P(L) = 1 - P(A) - P(B) = 1 - 0.40 - 0.35 = 0.25

You do not get to choose the leftover. On the dashboard, the third row printed 0.30; the forced leftover given the first two rows is 0.25. The table overspends by 0.05.

Complement as the simplest leftover

When there are only two pieces — an event and everything else — the leftover is the complement:

P(Ac)=1−P(A)=1−0.40=0.60P(A^c) = 1 - P(A) = 1 - 0.40 = 0.60

Same budget rule, fewer named outcomes.

Three budget rules (axioms)

Name them only after the picture:

  1. Nonnegative: P(E)≥0P(E) \ge 0 for every outcome set EE.
  2. Total: P(Ω)=1P(\Omega) = 1, where Ω\Omega is "something happens".
  3. Additivity for non-overlapping sets: P(A∪B)=P(A)+P(B)P(A \cup B) = P(A) + P(B) when A∩B=∅A \cap B = \varnothing.

Derive the leftover from 2 and 3: Ω=A∪B∪L\Omega = A \cup B \cup L with no overlaps, so 1=P(A)+P(B)+P(L)1 = P(A) + P(B) + P(L), hence P(L)=1−P(A)−P(B)P(L) = 1 - P(A) - P(B).

Derive the upper bound the same way: P(A)=1−P(Ac)≤1P(A) = 1 - P(A^c) \le 1 because P(Ac)≥0P(A^c) \ge 0. That sentence rejects a score of 1.7 before anything about summing.

Back to the dashboard

0.40 + 0.35 + 0.30 = 1.05 breaks the total rule. The fix is not "round down". One of these is not a probability — raw model scores, not masses. A single score of 1.7 breaks the nonnegative/upper-bound story before it breaks the sum. Lesson 14's softmax exists to spend this budget honestly.

Home numbers locked for the whole lesson (prose, figures, lab reset, quiz Q1, flashcard):

OutcomeMass
A0.40
B0.35
leftover (everything else)0.25
sum1
import numpy as np
m = np.array([0.40, 0.35, 0.25])
assert abs(m.sum() - 1) < 1e-12 and (m >= 0).all() and (m <= 1).all()
assert abs((1 - 0.40 - 0.35) - 0.25) < 1e-12
assert abs((0.40 + 0.35 + 0.30) - 1.05) < 1e-12  # ghost bar overspends by 0.05

Worked examples

Home: masses 0.40 and 0.35 → leftover 0.25; table sums to 1 → valid.

Wrong path: dashboard 0.40 + 0.35 + 0.30 = 1.05 → overspent by 0.05. A table 0.50 + 0.60 + x needs x=−0.10x = -0.10 → negative leftover, invalid.

Transfer: a three-class classifier gives cat 0.55 and dog 0.30. "other" must be 0.15. If it printed other 0.20, it is overspent by 0.05.

Score vs probability: raw scores [0.5, 0.4, 0.3] sum to 1.2 → not a distribution even though every entry is in [0, 1]. A single score 1.7 fails before summing.

Interactive lab

Two sliders set A and B. The third bar is computed by runProbL1 and is never draggable — the leftover is forced. When A+B>1A + B > 1, the leftover draws below the axis and the reason sentence prints. Reset returns to 0.40 / 0.35 / 0.25.

Interactive lab loads with the lesson app.

Failure modes

  1. "Probabilities are percentages of a hundred people." A mass is a share of a budget for one uncertain outcome; there need not be a hundred anythings. Spot it when a learner refuses 0.375 "because you cannot have 37.5 people".
  2. Negative leftover. If two masses already exceed 1, the table is wrong; the leftover is not "−0.10 of something".
  3. P(A)+P(Ac)≠1P(A) + P(A^c) \ne 1. Usually from overlapping events counted twice. Show 0.40 + 0.60.
  4. Scores are probabilities. A score of 1.7, or scores that sum to 1.2, are not leftover.

Honesty table

ClaimTag
Home masses 0.40, 0.35, 0.25 sum to 1REAL — numpy / kernel prove (docs/probability/setup/prove-home-numbers.py, runProbL1)
Dashboard 0.40 / 0.35 / 0.30 summing to 1.05ILLUSTRATION — teaching failure, not a product screenshot
Still prob_l1_leftover_bars / prob_l1_budget_stripILLUSTRATION — teaching diagrams on Worker CDN (HTTP 200 verified)
Softmax hook (Lesson 14)PUBLISHED — Goodfellow §3 / standard softmax-to-simplex; not proved on this page
Lesson videoshipped

Video

The lesson plate above is the narrated walk of the leftover-must-sum-to-1 lesson: the overspending dashboard, the budget picture with home masses 0.40 / 0.35 / 0.25, the three budget rules, scores versus leftover, and the lab where the third bar is never draggable. It is served from the SuperLearn media Worker; there is no second copy in the app bundle.

Sources

Rewrite, never paste: Bertsekas & Tsitsiklis 2e Ch. 1 (§1.1–1.2); Piech, Probability for Computer Scientists, Part 1; Goodfellow §3.1–3.3; MIT 6.041SC L1.

Next: what happens to the budget when we learn the email contains the word free (Lesson 2 — conditioning).