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.
Two masses fix the third: . A 0.30 bar would spend leftover that does not exist. [ILLUSTRATION]
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.
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:
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:
Same budget rule, fewer named outcomes.
Three budget rules (axioms)
Name them only after the picture:
- Nonnegative: for every outcome set .
- Total: , where is "something happens".
- Additivity for non-overlapping sets: when .
Derive the leftover from 2 and 3: with no overlaps, so , hence .
Derive the upper bound the same way: because . 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):
| Outcome | Mass |
|---|---|
| A | 0.40 |
| B | 0.35 |
| leftover (everything else) | 0.25 |
| sum | 1 |
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 → 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 , the leftover draws below the axis and the reason sentence prints. Reset returns to 0.40 / 0.35 / 0.25.
Failure modes
- "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".
- Negative leftover. If two masses already exceed 1, the table is wrong; the leftover is not "−0.10 of something".
- . Usually from overlapping events counted twice. Show 0.40 + 0.60.
- Scores are probabilities. A score of 1.7, or scores that sum to 1.2, are not leftover.
Honesty table
| Claim | Tag |
|---|---|
| Home masses 0.40, 0.35, 0.25 sum to 1 | REAL — numpy / kernel prove (docs/probability/setup/prove-home-numbers.py, runProbL1) |
| Dashboard 0.40 / 0.35 / 0.30 summing to 1.05 | ILLUSTRATION — teaching failure, not a product screenshot |
Still prob_l1_leftover_bars / prob_l1_budget_strip | ILLUSTRATION — 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 video | shipped |
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).
