Your model scores 84.3% and the old one 83.9% on 1,000 questions. Draw a fresh test set and the worse model wins about 4 times in 10. The gap is a quarter of the noise.
Pick a test-set size and press Draw 20 test sets. Count how often the worse model comes out on top. Then we build, piece by piece, the tools that tell signal from luck: the error bar, the honest interval, the paired test, power and the noise budget.
You need averages and a little probability (what "70% chance" means) and some Python for the code. We build the rest from zero.
Illustrative. We made up the true skills, 84.3% for A and 83.9% for B. Each draw samples a fresh test set of N questions for each model.
Chapter 0
See why a higher score can be luck, and compare every gap to the noise before you trust it
You fine-tuned a question-answering model for two weeks. On a 1,000-question benchmark it scores 84.3%. The production model scored 83.9%. A colleague says "ship it."
The eval code is deterministic, so where is the luck? It is in the questions. Your test set is a sample: 1,000 questions out of all the questions users could ask. Collect a different 1,000 and both scores move. The only question is whether they move by more than 0.4 points.
The hero above answers it. At N = 1,000 the worse model wins about 40% of fresh test sets. Two words name what you saw. Sampling error is how far a score jumps because the test set is finite. The noise band is the range a gap can reach by sampling error alone, about two noise units either side of zero.
Chapter 1 derives the size of one noise unit. For now take the result: each score here wobbles by about 1.2 points, and the gap between two scores by about 1.6 points. So the band runs from about −3.2 to +3.2 points. A gap of 0.4 sits deep inside it.
Teal is the gap you measured. Purple is the noise band. Drag the gap and the test-set size until the teal mark leaves the band.
Both scores near 84%, each on its own test set of N questions. The band is ±1.96 noise units, the 95% range of Chapter 2.
Here is the arithmetic for the gap. Divide it by one noise unit: 0.4 ÷ 1.64 = 0.24. The gap is a quarter of one unit. If the two models were equal, a gap this large or larger would still appear 81% of the time. So this result says nothing yet.
The symptom is a launch decision that flips when someone reruns the eval on new data. The measurement is the ratio of gap to noise unit. Below 2, you cannot tell. The fix is the rest of this lesson: measure the noise, use a paired test, and size the test set before you run it.
This lesson owns the statistics. Metric Design owns what to compute. Experiment Design owns tests with live users. Plots That Tell the Truth owns how to draw the error bars.
Chapter 1
Treat each question as a coin flip, derive one noise unit, and see why four times the data buys only twice the precision
On each question the model is right (1) or wrong (0). Accuracy is the average of those N ones and zeros. So accuracy is a sum of random things, and sums of random things behave in known ways.
Keep two numbers apart. The true accuracy is the model's skill over all possible questions. You never see it. The measured accuracy is the share right on your N questions. The measured value wobbles around the true one.
One flip has variance (the average squared distance from its mean) equal to true accuracy times (1 − true accuracy). Average N flips and the variance shrinks N times. Its square root is the standard error: the typical distance between measured and true accuracy.
Call the true accuracy p and the number of questions N.
S-E equals the square root of p times one minus p, all over N.
Multiply p by 1 − p to get the variance of one question. Divide by N. Take the square root. That is SE.
With made-up numbers: 425 of N = 500 right, so p = 0.85. Then 0.85 × 0.15 = 0.1275, divided by 500 is 0.000255, and the root is SE = 0.0160. Your "85%" is honestly 85 ± 1.6 points.
N sits under a square root. Quadruple the test set to 2,000 and SE falls to 0.8 points: half, not a quarter. Ten times the precision costs a hundred times the questions.
Each bar counts test sets whose measured accuracy fell there. The purple curve is the bell that SE predicts. Add test sets, then double N.
Illustrative simulation. Each test set draws N independent right-or-wrong answers at the true accuracy p.
Now compare two models, each on its own test set. Call their noise units SEA and SEB. Independent variances add, so the gap has its own noise unit.
S-E-diff equals the square root of S-E-A squared plus S-E-B squared.
Square each model's SE, add the squares, take the root. Never add the SEs themselves.
Chapter 0's models on N = 1,000: SEA2 = 0.843 × 0.157 / 1,000 = 0.000132 and SEB2 = 0.000135. The sum is 0.000267, so SEdiff = 0.0164, or 1.64 points.
The formula assumes independent questions. Ten questions about one document share a fate. Your effective N is then closer to the number of documents, and the true SE is larger. The fix is to compute SE over the document clusters.
Chapter 2
Wrap a score in a bracket that catches the truth 95 times in 100, and switch to Wilson when the test is small
Your agent solved 17 of 20 hard tasks. The launch doc says "85%." How far can a reader trust it?
A 95% confidence interval is a procedure. Draw a fresh test set 100 times, build the interval each time, and about 95 of the 100 intervals contain the true accuracy. The interval is the random thing. The truth stays fixed.
The common recipe is the Wald interval: the measured accuracy p̂ (say "p-hat"), plus and minus 1.96 noise units.
p-hat plus or minus one point nine six times S-E.
Compute SE from p-hat and N. Multiply by 1.96. Subtract it from p-hat for the low end and add it for the high end.
17 of 20: p-hat = 0.85 and SE = √(0.85 × 0.15 / 20) = 0.0798. Then 1.96 × 0.0798 = 0.156, so the interval is 0.694 to 1.006. The top end claims 100.6% accuracy, which is impossible.
Wald breaks when N is small or p-hat is near 0 or 1. The Wilson interval asks a better question: which true accuracies would make 17 of 20 unsurprising? Its centre moves toward 0.5, and it stays inside 0 to 1. Call the 1.96 z and the number of tasks n.
The centre equals p-hat plus z squared over two n, all divided by one plus z squared over n.
Add z-squared over 2n to p-hat. Divide by 1 plus z-squared over n. The half-width then uses the same divisor (see the code in the Field Guide).
z2 = 3.84 and n = 20, so z2/2n = 0.096 and z2/n = 0.192. Centre = 0.946 / 1.192 = 0.794, and the half-width is 0.154. Wilson says 64% to 95%: twenty tasks cannot tell a 65% agent from a 94% one.
Each line is one experiment's interval. Green caught the yellow truth, red missed it. Set p near 0.95 with n = 20, then switch Wald to Wilson.
Illustrative simulation. Over many runs at p = 0.95 and n = 20, Wald catches the truth about 64% of the time and Wilson about 92%.
Use Wald only when N × p-hat and N × (1 − p-hat) both exceed about 10. Otherwise use Wilson. For a safety claim, use the wider Clopper-Pearson interval, which never under-covers.
A safety eval finds 0 violations in 200 trials. Wald gives 0 ± 0. The symptom is a bracket of zero width that claims certainty. Wilson's top end is 1.9%. A quick check is the rule of three: with 0 events in n trials, the 95% top end is about 3/n, here 1.5%.
Chapter 3
Resample your one test set with replacement to fake many test sets, and read the error bar off the spread
Your dashboard shows accuracy, F1 and BLEU. Chapter 1's formula works for accuracy, because accuracy is an average of independent ones and zeros. F1 is a ratio of sums over the whole set. BLEU scores the whole corpus at once. Neither is an average of N independent things, so neither has a simple SE formula.
The bootstrap fakes fresh test sets. You cannot collect new questions, so you resample the ones you have. Each resample draws N questions from your N with replacement. After each draw the question goes back, so some appear twice and some not at all.
Top: the test set, teal right and red wrong; the small number counts how often the last resample drew each tile. Bottom: one dot for each resample. Draw one, then a thousand.
Illustrative toy test sets. The 10-item set matches the worked example below.
Worked by hand on the 10-item set, [1,1,0,1,1,1,0,1,1,0], accuracy 0.70. One resample draws indices [3,0,7,7,2,9,4,1,5,8]. Index 7 comes twice and index 6 never, so the values sum to 8 and the accuracy is 0.80. Another resample gives 0.60.
Over 10,000 seeded resamples the interval is 0.40 to 1.00. The spread of the resamples is 0.144, and Chapter 1's formula gives √(0.7 × 0.3 / 10) = 0.145. The two methods agree.
Why does it work? Your test set is the best picture you have of the full question pool. Sampling from it mimics sampling from the pool. This is the plug-in principle. On average, a resample leaves out about 36.8% of the questions.
Resample the right unit. A dialogue benchmark has 200 conversations of about 10 turns each, and turns in one conversation share a user and a topic. Resample the 2,000 turns one by one and the interval comes out too narrow. That is the symptom. The fix is to resample whole conversations. For a corpus metric like BLEU, resample sentences and recompute corpus BLEU each time; do not average per-sentence BLEU.
Chapter 4
Ignore the questions both models agree on, and test only the ones where they disagree
Models A and B answer the same 1,000 questions. A scores 85.5% and B 83.5%. The unpaired test from Chapter 1 gives p = 0.22. The test in this chapter, on the same data, gives p = 0.023. Only the method changed.
First the vocabulary. The null hypothesis says the two models are equally accurate. The p-value is the chance of a gap at least this large if the null were true. It is not the chance that the null is true.
On the same exam, most questions come out the same for both models: easy ones both right, hard ones both wrong. That shared part says the question was easy or hard. It says nothing about which model is better. Split the questions four ways.
| B right | B wrong | |
|---|---|---|
| A right | a = 810 | b = 45 |
| A wrong | c = 25 | d = 120 |
Only the discordant cells, where the models disagree, carry the comparison. Call the A-only count b and the B-only count c. If the models are equal, each discordant question is a fair coin. McNemar's test measures how far the split is from even.
Chi-squared equals the size of b minus c, minus one, squared, over b plus c.
Subtract c from b and drop the sign. Take away 1 and square it. Divide by b plus c. A large chi-squared means the split is far from a fair coin.
b = 45 and c = 25: (20 − 1)2 / 70 = 361 / 70 = 5.16, so p = 0.023. The exact coin-flip test, 45 or more heads in 70 tosses either way, gives 0.022.
1,000 dots, one per question. Grey means the models agree. Teal is A-only right, warm is B-only right. Slide the counts and watch the two p-values part.
Illustrative counts. The agreements fill the rest of the 1,000, split 87 to 13 between both right and both wrong.
Why the gap in p-values? The unpaired noise unit was 1.62 points, because it counts each model's luck on the 930 shared questions. The paired noise unit of the same 2-point gap is 0.83 points. For metrics other than accuracy, use the paired bootstrap: resample question indices once, score both models on the same resample, and record the gap. Here it gives a 95% interval of 0.4 to 3.6 points.
Chapter 5
Work out how many questions you need before you run the eval, and stop reading misses as ties
A teammate claims a 1-point improvement. Your 1,000-question eval shows +1.1 points, not significant. Did the change fail, or could the eval never have seen it?
A test can fail two ways. A false alarm declares a gap that is not there; its rate is α (alpha), set to 0.05. A miss fails to find a gap that is there; its rate is β (beta). Power is 1 − β, the chance you catch a real gap. Teams aim for 80%.
Purple is the gap you would see if the models were equal. Teal is the gap you would see if the true gap is real. Green is the share of teal past the blue cutoff: the power.
Baseline accuracy 85%, two-sided α = 0.05, unpaired, normal approximation.
To catch the gap 80% of the time, it must sit about 2.8 noise units from zero. That is 1.96 for the cutoff plus 0.84 for the 80%. Call those zα/2 and zβ, the two accuracies p1 and p2, and their gap δ. Solve for the questions per model, n.
n equals z-alpha-over-two plus z-beta, squared, times p-one times one minus p-one plus p-two times one minus p-two, over delta squared.
Square 2.80 to get 7.85. Multiply by the noise of the two models. Divide by the squared gap. That is n.
85% against 86%: the noise is 0.1275 + 0.1204 = 0.2479 and δ2 = 0.0001. Then n = 7.85 × 0.2479 / 0.0001 = 19,458 questions per model.
The formula squares δ, so halving the gap quadruples n. A 2-point gap (85% against 87%) needs 4,722. A half-point gap needs about 79,000. Turn the formula around to get the minimum detectable effect: the smallest gap your N can see with 80% power. At 1,000 per model near 85%, it is about 4.4 points. HumanEval has 164 problems, so near 85% it can only see gaps of about 11 points.
The symptom is a team that reads "not significant" as "no effect." The measurement is the power at the gap you care about: for 1 point at N = 1,000 it is about 10%. The fix is to compute n before the run, pair the test (Chapter 4), or declare small gaps out of reach.
Chapter 6
Count your attempts before you trust the best one, and raise the bar to match
You tried 20 prompt variants. One beats the baseline at p = 0.03. Before you celebrate, ask how often pure noise gives you at least one such win.
Each test at α = 0.05 has a 5% false-alarm rate. Call the number of tests m. If none of the variants helps, each test stays quiet with chance 1 − α, and all m stay quiet with that chance multiplied m times.
The chance of at least one false win equals one minus, one minus alpha, to the m.
Raise 0.95 to the power m: the chance all m tests stay quiet. Subtract from 1.
m = 20: 0.9520 = 0.358, so the chance of a fake win is 1 − 0.358 = 64%. The sweep almost hands you a win.
Each dot is one config's p-value, sorted from smallest. The blue line is the bar a p-value must clear. Red dots are fake wins. Run the sweep, then pick a correction.
Illustrative. A useless config's p-value is uniform from 0 to 1. The planted real win has a true effect of about 3 noise units.
Two corrections. Bonferroni asks each test to clear α/m: 0.05/20 = 0.0025. It keeps the chance of any false win under 5%, but it is harsh when m is large. Benjamini-Hochberg (BH) controls the false discovery rate: on average, at most 5% of your declared wins are false.
With ten p-values [0.001, 0.004, 0.012, 0.021, 0.041, 0.09, 0.13, 0.22, 0.45, 0.78], the bars are 0.005, 0.010, 0.015, 0.020 and so on. The third passes and the fourth fails, so BH declares 3 wins. Bonferroni declares 2, and no correction declares 5.
Seeds are the same trap. Five seeds of one config score [84.1, 83.5, 84.8, 83.9, 84.4]: mean 84.14, standard deviation 0.49. Reporting the best seed, 84.8, against a rival's mean is shopping. The fix: name one primary metric before the sweep, and confirm the single winner once on a held-out set.
Chapter 7
Set the true skills yourself, run the eval again and again, and watch the ranks reshuffle on noise
Eight models, all with true accuracy 85%. Each run draws a fresh test set for each model and ranks them. The podium changes every run, and it looks just as official either way.
A rank is an order statistic: a position in a sorted list of noisy scores. Two models swap whenever their gap is small next to the noise of the gap. Eight models make 28 pairs, so some pair swaps on almost every run. Rank 1 goes to the luckiest model, so its score sits above its true skill. This is the winner's curse.
Left: scores sorted by this run, with a yellow tick at each model's true skill. Right: each model's rank over recent runs; bright is rank 1. Set the gap to 0, shrink N, and watch the podium.
Illustrative. "True gap" is the distance in points between neighbouring models' true skills, centred on 85%. Each model gets its own test set of N questions.
Now the arithmetic for two models. A has true accuracy 86% and B 85%, each on its own 500 questions. The noise unit of the gap is √(0.86 × 0.14 / 500 + 0.85 × 0.15 / 500) = 2.2 points, against a true gap of 1 point. B comes out on top whenever the noise beats the gap: 1 ÷ 2.2 = 0.45 noise units, which happens 33% of the time. At 5,000 questions the noise unit falls to 0.70 points and the flip rate to 8%.
Turn on the intervals. At N = 500 all eight overlap, yet the rank column still prints 1 to 8. The most official-looking number on the page has the least support.
Three sliders give three rules. More questions calm the churn (Chapter 1). More models add churn (Chapter 6). Gaps under about two noise units keep swapping (Chapter 5).
Real leaderboards add human selection on top. The Leaderboard Illusion (Singh et al., 2025) reports that some providers tested many private variants on Chatbot Arena and showed only the best. It counts 27 private variants from one provider before one release. GSM1k (Zhang et al., 2024) rewrote grade-school maths problems from scratch and saw accuracy drops of up to 8 points for some models. That is memorisation, which no error bar catches.
An honest leaderboard prints an interval beside each score. It groups models whose intervals overlap into one tier. It uses paired tests on a shared test set and averages several runs for sampled decoding.
Chapter 8
Split the error bar into its sources, add them as variances, and spend your budget on the biggest one
Rerun the same model on the same test set with a new training seed, and the score moves. So the noise is not one thing. A modern eval has three main sources.
Call their standard deviations σseed, σtest and σdecode. Independent sources add as variances, the squares, so the total is a root of a sum.
Sigma-total equals the square root of sigma-seed squared plus sigma-test squared plus sigma-decode squared.
Square each source's standard deviation. Add the three squares. Take the root. The largest source dominates.
With made-up numbers: σseed = 0.6, σtest = 1.0, σdecode = 0.4. The squares are 0.36 + 1.00 + 0.16 = 1.52, so σtotal = 1.23 points, not 0.6 + 1.0 + 0.4 = 2.0.
The stacked bar shows the three variances. The bracket above is the total error bar; the ghost bracket is where you started. Buy down a source and compare the cost.
Illustrative. Start: σseed 0.6, σtest 1.0, σdecode 0.4 points. The cost units are illustrative: 30 per extra seed, 10 per extra test set, 2 per extra decode run.
Averaging attacks one source each. Averaging s seeds divides seed variance by s. A test set k times larger divides test variance by k. Averaging r decode runs divides decode variance by r.
With the numbers above, 3 seeds bring the total from 1.23 to 1.13 points, while 4 times the test set brings it to 0.88. Removing decode noise entirely only reaches 1.17. Removing both seed and decode noise leaves 1.00, the test-set noise alone.
To measure the sources, train S seeds and run the eval R times on each. The spread of the per-seed averages estimates seed noise. The spread of runs within a seed estimates decode noise. Madaan et al. (2024) measured seed variance across many benchmarks and urge you to account for it before comparing models.
The failure: you set temperature to 0 and fix the seed, then call the eval clean. You zeroed the small terms and changed what you measure, since users see sampled answers. The fix: state which sources an error bar includes, as in "84.1 ± 1.2 (3 seeds × 5 runs, all sources)."
Chapter 9
Keep the numbers, the checklist and the code in one place
A score is a random variable. Give it an interval, compare models paired, size the test set first, count your attempts, and know which noise your error bar covers.
| What | Number | Why it matters |
|---|---|---|
| SE at 85%, N = 500 | 1.6 points | A 1-point claim is inside one noise unit |
| Worst-case SE, 0.5/√N | N = 100: 5; 1,000: 1.6; 10,000: 0.5 points | Triage any gap in your head |
| ±1 point for any accuracy | 9,604 questions | (1.96 / 0.01)2 × 0.25; ±2 needs 2,401 |
| 17 of 20, Wilson | 64% to 95% | Wald gives 69% to 101% |
| Same data, two tests | unpaired p = 0.22; McNemar p = 0.023 | Pairing is free power |
| 1-point gap at 85%, 80% power | 19,458 per model | Halving the gap quadruples n |
| Minimum detectable effect, N = 1,000 | about 4.4 points | Smaller claims are out of reach |
| 20 useless tests at α = 0.05 | 64% chance of a fake win | Correct, or confirm on held-out data |
| 1-point-worse model, N = 500 | wins 33% of runs | Ranks are noisier than scores |
| Seed 0.6, test 1.0, decode 0.4 | total 1.23 points | Variances add; buy down the largest |
| Your claim | Tool | Chapter |
|---|---|---|
| One model's score | Wilson interval; bootstrap for F1, BLEU or a judge | 2, 3 |
| Two models, same test set | McNemar, or the paired bootstrap | 4 |
| Two models, different test sets | Unpaired z-test with SEdiff; check power first | 1, 5 |
| Best of many configs | BH or Bonferroni, then one held-out confirmation | 6 |
| A single training run | Seeds × runs grid; report mean ± std | 8 |
| Term | Meaning |
|---|---|
| Standard error | The typical distance between the measured score and the true score. |
| Confidence interval | A bracket from a procedure that catches the truth 95 times in 100. |
| Bootstrap | Resample your test set with replacement to fake fresh test sets. |
| p-value | The chance of a gap this large if the models were equal. |
| Power | The chance a test catches a gap that exists. |
| Minimum detectable effect | The smallest gap your test set can see with 80% power. |
| False discovery rate | The share of declared wins that are false, on average. |
| Winner's curse | The top score of many noisy scores sits above its true value. |
pythonimport math, numpy as np from scipy import stats def wilson(k, n, z=1.96): # k right out of n p, zz = k / n, z * z centre = (p + zz / (2 * n)) / (1 + zz / n) half = z * math.sqrt(p * (1 - p) / n + zz / (4 * n * n)) / (1 + zz / n) return centre - half, centre + half # wilson(17, 20) -> (0.640, 0.948) def mcnemar_p(a_right, b_right): # two 0/1 arrays over the SAME questions b = int(np.sum(a_right & ~b_right)); c = int(np.sum(~a_right & b_right)) return min(1.0, 2 * stats.binom.sf(max(b, c) - 1, b + c, 0.5)) # exact; 45 vs 25 -> 0.022 def paired_bootstrap(sa, sb, metric, B=10000, seed=0): # per-question outputs of A and B rng, n = np.random.default_rng(seed), len(sa) gaps = [metric(sa[i]) - metric(sb[i]) for i in (rng.integers(0, n, n) for _ in range(B))] return np.percentile(gaps, [2.5, 97.5]) # same indices for both models def required_n(p1, p2, alpha=0.05, power=0.8): z = stats.norm.ppf(1 - alpha / 2) + stats.norm.ppf(power) return math.ceil(z ** 2 * (p1 * (1 - p1) + p2 * (1 - p2)) / (p2 - p1) ** 2) # (0.85, 0.86) -> 19458 def benjamini_hochberg(ps, alpha=0.05): # returns indices of declared wins order, m = np.argsort(ps), len(ps) ok = [k + 1 for k, j in enumerate(order) if ps[j] <= (k + 1) / m * alpha] return set(order[:max(ok)]) if ok else set()
Every tool here measures sampling noise inside one fixed question pool. None detects contamination, distribution shift, a harness bug that repeats the same wrong score, or a metric that measures the wrong thing. Statistics says the measurement is precise. It cannot say it is the right measurement.
Now press Present or Teach and explain four things from memory. One noise unit. Why Wilson beats Wald on 17 of 20. Why pairing turns p = 0.22 into 0.023. Why a 1-point gap needs 19,458 questions. Then go back to the hero, pick N = 1,000, and say how many draws the worse model should win.