Key takeaways
- ✓Test cases for a margin: about z² × p(1−p) ÷ margin², with z = 1.96 for 95% confidence and p the score you expect. At about 90% right: ±3 points takes 385 cases, ±2 takes 865, ±1 takes 3,458, ±0.4 takes 21,609. The margin is squared, so half the margin costs 4× the cases and a 5× thinner one 25×.
- ✓Price a margin in labeling time, not model calls. At the lab's example costs ($1 a label, $0.006 a model + judge run), ±0.4 points costs $21,739, of which $130 is model calls, and 540 hours of a person's time: over three months of full-time work.
- ✓Plan with the score you expect, and know what a wrong guess costs. 50% is the safe guess (scores vary most there): ±2 points takes 2,401 cases instead of 865. A plan made for 90% that meets a system at 70% gives ±3.1 points, not ±2.
- ✓'Is the new version better?' is a different question with a different size. Power is how often a test notices a real difference. With 100 cases per version, a real gain from 80% to 82% was noticed in 6.1% of 2,000 simulated comparisons; 80% power takes 12,078 labeled cases on different cases.
- ✓'Not significant' means the test couldn't tell. One 100-case comparison of that real +2 gave 85 vs 85, a range of −10.1 to +10.1 points. Report the range, not 'no difference'.
- ✓Run both versions on the same cases (a paired comparison). Cases both get right or both get wrong carry no information; only disagreements count, about 1 case in 8 here. That took 80% power from 12,078 labeled cases to 2,423, when the versions behave alike case by case (ρ = 0.6).
- ✓Keep the labels. Later versions run on the same labeled cases for the price of model calls ($15 a check), so 10 changes cost $2,583 instead of $66,828. Answer a precision request with its price, the decision it serves, and cheaper options that say what they give up.
"Can we measure the assistant's accuracy to ±0.4%?" sounds like a reasonable request before a launch. Worked out, it is 21,609 test cases, each answer checked by a person: 540 hours of labeling and $21,739 before the first result. This chapter turns a margin into a number of test cases and a budget, shows why "is the new version better?" needs a different plan, and how comparing versions on the same test cases, and keeping the labels, makes the second question cheap. It ends with a reply to the ±0.4% request.
The examples come from Lab 03 (The ±0.4% Problem) of the AI evaluation labs: 01_sample_size.py (from a margin to a number of test cases), 02_comparisons.py (sizing a comparison of two versions, checked by simulation) and 03_cost.py (dollars and labeling hours, and the reply), with the lab's planning functions in evalkit/planning.py. Everything here is planning math and simulation; nothing calls a real AI system. The ±0.4% request is a made-up example, and the costs are the lab's example unit costs (in data/costs.json; change them for yours). The lab's command-line planner (04_plan.py) and its two plotting exercises aren't covered; the finite population correction and the pilot get a short section each.
Three words, and a margin
- A test case is a question for the assistant plus its right answer. A person has to check the answer the assistant gives; that check is a label.
- The score is the share of test cases the assistant gets right.
- A score measured on a sample wobbles: test on different cases and you get a slightly different score. Chapter 1 put a confidence interval around it, the range the true score probably lies in (95% of the time). The margin is half its width: "90%, ±3 points", like a poll.
±0.4 is a very thin margin. Measure 90% and the truth is probably between 89.6% and 90.4%.
What a margin costs
Chapter 1 went from cases to a margin. Turn the same formula around and you get the cases for a margin:
test cases ≈ z² × p(1 − p) ÷ margin²
z = 1.96 for 95% confidence, p = the score you expect, margin as a share (0.02 for 2 points)
1.96² × 0.9 × 0.1 ÷ 0.02² = 864.4, rounded up to 865
| Margin (95% confidence) | At about 90% right | At 50% (the safe guess) |
|---|---|---|
| ±3 points | 385 | 1,068 |
| ±2 points | 865 | 2,401 |
| ±1 point | 3,458 | 9,604 |
| ±0.4 points | 21,609 | 60,023 |
From ±2 to ±0.4 the margin got 5× thinner and the cases went up 25×. The margin is squared in the formula, so half the margin costs 4× the cases: the same rule as Chapter 1's "half the wobble takes four times the cases". The confidence level matters much less: at 90% right and ±2 points, 99% confidence takes 1,493 cases instead of 865, 1.7×.
Pick a margin: how far the true score may be from the measured one (95% of the time). The left bar is where the truth could be; the right bar is how many hand-labeled test cases it takes.
Margin
True score could be (86.5–93.5%)
Test cases (log scale)
At about 90% right, ± 0.4 points needs 21,609 labeled cases: 540 hours of a person's time, about 14 weeks of full-time work, before the first result. A 5× thinner margin than ± 2 points, and 25× the cases.
Case counts: the lab's n_for_margin at 95% confidence. Cost: the lab's example unit costs, a label at $1 (1.5 minutes at $40 an hour) plus $0.006 of model and judge calls per case. Change them for yours.
The formula needs the score you're trying to measure. p(1 − p) is largest at 50%, so planning for 50% always meets the target, at up to 2.8× the cases of a 90% plan (2,401 against 865 for ±2 points). Plan for 90% and get it wrong, and the margin is wider than promised: the 865-case plan gives
| The system really scores | 97% | 95% | 90% | 85% | 80% | 70% | 50% |
|---|---|---|---|---|---|---|---|
| Margin from 865 cases | ±1.1 | ±1.5 | ±2.0 | ±2.4 | ±2.7 | ±3.1 | ±3.3 |
The middle path: plan with the lowest score you'd believe, or run a small pilot first and top up the sample. This is planning math (the normal approximation); for reporting a measured score, use a Wilson interval from Chapter 1, which stays sensible near 0% and 100%.
One case where you need fewer: a small, fixed population. If the question is about last month's 2,000 support tickets, not all future traffic, ±2 points takes 604 tickets instead of 865 (the lab's finite population correction), and ±0.4 takes 1,831, 92% of them: label them all. For 100,000 requests it barely matters (857 instead of 865).
What ±0.4 costs
A label costs the lab's example $1: a minute and a half of a person's time at $40 an hour. Running the model and a judge on a case costs $0.006 together.
| Margin, at about 90% right | Test cases | Labeling time | Model + judge | Total |
|---|---|---|---|---|
| ±3 points | 385 | 10 h | $2 | $387 |
| ±2 points | 865 | 22 h | $5 | $870 |
| ±1 point | 3,458 | 86 h | $21 | $3,479 |
| ±0.4 points | 21,609 | 540 h | $130 | $21,739 |
Model calls are a rounding error; labeling is the cost. 540 hours is over three months of one person's full-time work before a single number comes out. Seen the other way (the lab's Exercise 4 of 03_cost.py), $1,000 buys a ±1.9-point margin and $25,000 buys ±0.4.
Is the new version better?
That is usually not the real question. The real one is: is the new version better than the old one? It's a different question, and it is sized differently.
- The minimum detectable effect is the smallest real difference you want to be able to see. It should come from the decision: "we'd ship the new prompt for +2 points".
- Power is how often a test notices a real difference of that size. The usual goal is 80%: four times in five.
- A test "notices" when the difference it measures is clearly bigger than noise; the usual word is significant (at the 95% level, here). "Not significant" means "not clearly bigger than noise".
The lab's example: the old version gets 80% right, the new one truly 82%. 02_comparisons.py simulated that comparison 2,000 times per design and counted how often the new version came out clearly ahead:
| Design | Labeled cases | Noticed (simulated) | Power (formula) |
|---|---|---|---|
| 100 cases per version, different cases | 200 | 6.1% | 5% |
| 500 cases per version, different cases | 1,000 | 12% | 12% |
| 500 shared cases, both versions on each | 500 | 21% | 25% |
| 6,039 per version, different cases | 12,078 | 80% | |
| 2,423 shared cases, both versions on each | 2,423 | 80% |
With 100 cases each, the test notices a real 2-point gain about 6 times in 100: it almost always misses. Halving the gain you want to see costs about 4× the cases, as with margins: +1 point takes 49,282 labeled cases on different cases.
The old version gets 80% right; the new one truly gets 82%. Pick how the comparison is run.
Of 100 such tests (simulated)
lit = noticed the gain
One such test: the range for new minus old (points)
Old: 85 of 100. New: 85 of 100. Measured +0.0 points, range −10.1 to +10.1: not significant. The test couldn't tell; the real +2 is inside the range.
Simulated: 2,000 made-up comparisons per design, not a real AI. "Noticed" means the test showed the new version clearly ahead at the 95% level. The single test is one separate draw (the lab's Exercise 3); its range is a Newcombe interval for different cases and a paired interval for shared ones. The 2,400-case paired test has no simulated rate: its formula power is 80%, the same as the lab's 2,423-case plan.
"Not significant" isn't "no difference"
02_comparisons.py then draws one test per design, each facing the same real +2 points:
| Design | Measured (new − old) | Range for the difference (95%) | Significant? |
|---|---|---|---|
| 100 per version, different cases | +0.0 (85 vs 85 of 100) | −10.1 to +10.1 | no |
| 500 per version, different cases | −1.0 | −5.9 to +3.9 | no |
| 500 shared cases | +1.0 | −2.1 to +4.1 | no |
| 2,400 shared cases | +1.8 | +0.4 to +3.2 | yes |
In the first row luck lifted the old version to 85 instead of 80, and the two tied. It's tempting to write "the new version made no difference". But the range runs from a ten-point loss to a ten-point gain, and the real +2 sits inside it. The test couldn't tell. (For different cases the range is a Newcombe interval, built from the two scores' Wilson intervals; for shared cases it comes from the disagreements alone.)
So report the range, not "no difference". A change is shown to be harmless only when the whole range sits inside what you'd accept, for example "no worse than −1 point".
Two students, one exam
How do you catch two points without a mountain of labeled cases? Think of two students. Give them different exams and one might just get the easier exam. Give them the same exam and that luck is gone.
Test cases work the same way. A paired comparison runs both versions on the same test cases. Most cases both get right, some both get wrong, and those say nothing about which is better. Only the cases where they disagree count (McNemar's test, the standard test for this, uses only those). In the lab's model, a typical 100 shared cases are 75 both right, 13 both wrong, 5 right only for the old version and 7 only for the new: about 1 case in 8 disagrees, and the 2-point gain is the 7 against the 5.
How many disagree depends on how alike the two versions behave case by case: the correlation ρ (rho), from 0 (unrelated) to 1 (they always get the same cases right). Two versions of one assistant are usually alike, because a prompt tweak rarely changes which questions are hard. For the 2-point gain at 80% power:
| Design | Cases that disagree | Labeled cases |
|---|---|---|
| Different cases for each version | 12,078 (6,039 each) | |
| Same cases, ρ = 0.3 | 21.6% | 4,233 |
| Same cases, ρ = 0.6 | 12.4% | 2,423 |
| Same cases, ρ = 0.8 | 6.2% | 1,217 |
The lab's examples use ρ = 0.6: five times fewer labeled cases. (Some combinations can't exist: 80% and 90% right can't be as alike as ρ = 0.8, because the better version has to get 10 extra cases in 100 right on its own.)
Which student is better? Give them different exams and one may just get the easier exam. Give them the same exam and that luck cancels. Here the students are the old version (80% right) and the new one (truly 82%), and the exam is 100 test cases.
Cases both get right or both get wrong say nothing about which is better. Only the 12 in 100 where they disagree do, and the new one wins 7 of them to the old one's 5. To catch the 2-point gain 4 times in 5: 2,423 shared labeled cases, against 12,078 on different cases (5.0× fewer).
Labels you keep · total cost after 10 changes
The lab's cost arithmetic at its example unit costs: the first paired comparison labels 2,423 cases and runs both versions ($2,452); each later change runs only the new version on the same labels ($15). Without pairing, the first comparison labels 12,078 cases ($12,150) and each later change 6,039 fresh ones ($6,075). The grid above is the lab model's expected mix per 100 shared cases, rounded to whole cases and placed at random positions; it is not a measured run.
You don't know ρ in advance. Run both versions on a small pilot and count the disagreements. In the lab's Exercise 4, five 200-case pilots estimated a disagreement rate of 12–15%, giving plans of 2,353 to 2,941 cases against 2,423 with the true rate; round up. Use the pilot only for the disagreement rate, never for the effect: one of those pilots had the old version ahead, 17 disagreements to 9, although the new one is truly better.
Labels you keep
Pairing saves a second time. Labels are the expensive part. With the same cases, you label them once, and every later version just runs on them. With different cases, every new version needs thousands of freshly labeled ones. 03_cost.py prices 10 changes, each checked for a 2-point gain at 80% power:
| First comparison | Each later change | 10 changes | |
|---|---|---|---|
| Different cases | $12,150 (12,078 labels) | $6,075 (6,039 new labels) | $66,828 |
| Same cases, labels reused | $2,452 (2,423 labels, both versions run) | $15 (model calls only) | $2,583 |
A labeled set you keep is an asset; it pays for itself on the second comparison. That's what a golden dataset is: a fixed, labeled set of test cases every version is checked on.
The reply to "we need ±0.4%"
Don't say no. Ask first what decision the number supports; a figure like ±0.4% is usually copied from somewhere, not derived from a decision. Then price options, each with what it gives up. From 03_cost.py's Exercise 3, at about 90% right:
| Option | Test cases | Labeling | Total | What it gives up |
|---|---|---|---|---|
| A. ±0.4 points, as asked | 21,609 | 540 h | $21,739 | Nothing; three months of labeling |
| B. ±1 point, to report a quality number | 3,458 | 86 h | $3,479 (6× cheaper) | Two such scores can't be told apart if they're less than about 1.4 points apart |
| C. ±2 points, plus paired checks on the same labeled cases | 1,549 | 39 h | $1,558, then about $9 per new version | Won't reliably see drops smaller than 2 points |
Option C needs fewer cases than the 2,423 above because it's planned at about 90% right, catching a drop from 90 to 88: at 90% the versions disagree less (7.9% of cases), so fewer cases carry the same information. The 1,549 cases also cover the ±2-point score, which needs only 865. If a half-point change would really change a decision, size for that, and it will cost close to option A.
Caveats
- Planning math, not measurement. Every count here is a formula or a simulation in the lab. The detection rates are 2,000 simulated comparisons; the single tests are one simulated draw each. Real numbers depend on your score, your ρ and your unit costs.
- The simulated and formula detection rates differ a little. For 100 cases each, 6.1% simulated against 5% by the formula. That gap is rounding plus noise: the formula gives 5.5% before rounding, and a rate from 2,000 simulated comparisons wobbles by about ±1 point. Both say the same thing: the test almost always misses.
- The paired grid is an expected mix, the lab model's per-100-case average rounded to whole cases, not a measured run.
- A paired comparison is only as good as its shared cases. If the golden set doesn't represent real traffic, both versions are compared on the wrong cases. That's the next chapter's subject.
- Example unit costs. $1 a label assumes 1.5 minutes per case; expert labels (medical or legal content, say) cost far more and shift every row toward fewer cases.
- Option C's $1,558 covers the new version's runs only. The first paired check also runs the old version on the same 1,549 cases, about $9 more in model calls. It doesn't change the comparison.
The checklist
- Ask what decision a precision target supports before building for it.
- Turn the margin into test cases (z² × p(1 − p) ÷ margin²) and the cases into labeling hours and dollars.
- Plan with a cautious score: the lowest you'd believe, or 50% if you have no idea, or a pilot.
- Size comparisons separately: pick the smallest change that matters and aim for 80% power.
- Report the range for a difference, never "no difference" from a test that wasn't significant.
- Compare versions on the same test cases, and estimate the disagreement rate with a small pilot.
- Keep the labeled set and rerun every new version on it.
- Offer priced options, each with what it gives up.
Practice: size the eval
Write the lab's planning functions: the cases for a margin, the margin a plan really gives, the cost of a design, the cases for a comparison on different cases and on the same cases, and the cost of 10 changes both ways. The tests use the lab's numbers: 385 / 865 / 3,458 / 21,609, $21,739 and 540 hours, 12,078 against 2,423, option C's 1,549, and $66,828 against $2,583.
Quiz
1.At about 90% right, ±2 points takes 865 test cases. Roughly how many does ±1 point take?
2.Measuring ±0.4 points at the lab's unit costs comes to $21,739. What is most of that money?
3.Old version 80% right, new one truly 82%. A team compares them on 100 different cases each. How often does that test show the new one clearly ahead?
4.A 100-case comparison of that real +2 gain came back 85 vs 85: 'not significant', with a range of −10.1 to +10.1 points. What do you report?
5.Why does running both versions on the same test cases need so many fewer labeled cases?
6.Your manager asks for the score to ±0.4 points. What's the best first reply?
Check your understanding
Try each question before opening its answer.
How do you work out the number of test cases for a ±margin, and why does ±0.4 points need so many?
Test cases ≈ 1.96² × p(1 − p) ÷ margin², with p the score you expect. The margin is squared, so a 5× thinner margin costs 25× the cases: at about 90% right, ±2 points takes 865 and ±0.4 takes 21,609, about $21,739 and 540 hours of labeling at the lab's example costs.
What score should you plan with when you don't know it yet?
50% is the safe guess: p(1 − p) is largest there, so the plan always meets the target, at up to 2.8× the cases of a 90% plan. A plan made for 90% that meets a system at 70% gives ±3.1 points instead of ±2. The middle path is the lowest score you'd believe, or a small pilot and a top-up.
When does a small population mean fewer cases?
When the question is about a fixed, closed set and the sample is a sizable share of it. For last month's 2,000 tickets, ±2 points takes 604 instead of 865; for 100,000 requests it barely matters (857). It doesn't apply to all future traffic, which isn't a fixed set.
What are power and the minimum detectable effect, and how do they set the size of a comparison?
The minimum detectable effect is the smallest real difference you need to see, set by the decision. Power is how often a test notices a real difference that size; 80% is the usual goal. With 100 cases per version a real 80% → 82% gain was noticed 6.1% of the time in 2,000 simulated comparisons; 80% power takes 12,078 labeled cases on different cases. Halving the difference costs about 4× the cases.
Why does a paired comparison need fewer cases, and what decides how many fewer?
Both versions run on the same cases, so the luck of which cases were picked cancels, and cases both get right or both get wrong carry no information; only the disagreements count. How many fewer depends on how alike the versions behave case by case (ρ): for the 2-point gain, 4,233 at ρ = 0.3, 2,423 at 0.6, 1,217 at 0.8, against 12,078 on different cases. A small pilot estimates the disagreement rate.
A comparison isn't significant. What do you report?
The range for the difference. One 100-case comparison of a real +2 points came back 85 vs 85, with a range of −10.1 to +10.1: consistent with a big loss and a big gain. "Not significant" means the test couldn't tell. A change is shown harmless only when the whole range is inside what you'd accept.
How would you answer a request for ±0.4%?
Not with no. Show the cost (21,609 labeled cases, 540 hours, $21,739), ask which decision it serves, then offer options: ±1 point to report a quality number (3,458 cases, 6× cheaper, can't separate scores under about 1.4 points apart), or ±2 points plus paired checks on a reused labeled set (1,549 cases, about $9 per later check, misses drops under 2 points).
Next up: Chapter 3, stratified sampling: this chapter sized one score for one population. Real traffic has segments, including a rare 1% of critical requests a random sample can miss entirely; the next chapter sizes each segment, oversamples the rare ones and reweights the overall score.