Statistics for experiments and evals¶
Every claim that one model, prompt or training trick beats another is a statistical claim: a benchmark is a sample of questions, model outputs are random, training runs vary by seed. This page is the toolkit for making those claims honestly: standard errors, confidence intervals, paired comparisons, power, multiple comparisons, pairwise-preference models and online experiments.
10,000 ft
AI progress is measured. Leaderboards rank models, papers report gains of one or two points, teams ship prompt changes because an eval went up, and arenas rank chatbots from human votes. Each of those numbers is an estimate with noise, and the noise is often as large as the effect being claimed. The statistics here is old (Student 1908, Fisher 1925, Efron 1979), but its application to AI evaluation is recent and still under-practised: Miller (2024) set out how to put error bars on LLM evals, and studies of NLP and RL experiments found many comparisons underpowered or unreproducible. This page builds on the \(1/\sqrt{n}\) law of probability foundations and the estimators of estimation, and it is the maths behind evals in practice, benchmarks and metrics and validation.
2,000 ft
Treat every score as an estimate of what you would get on the whole universe of questions (or users, or seeds) you care about, then follow the chain below.
- Identify the unit of randomness: what would change if you reran the experiment?
- Report the estimate with a standard error or confidence interval.
- Compare models on the same items and analyse the paired differences.
- Decide in advance how much data you need (power).
- Correct for many comparisons and don't stop when the number looks good.
- Decide on the size of the effect and its uncertainty, not on "significant or not".
Ground level¶
An eval score is an estimate¶
A model answers 500 benchmark questions and gets 400 right: 80%. That 80% is the mean of 500 Bernoulli outcomes, and the question set is one sample from the much larger universe of questions the benchmark is meant to represent. Rerun with a different 500 questions of the same kind and you would get a different number. The standard error (SE) measures how much:
here \(\sqrt{0.8 \times 0.2 / 500} = 0.018\), or 1.8 points. By the central limit theorem the estimate is approximately Gaussian, so a 95% confidence interval is \(\hat p \pm 1.96\,\operatorname{SE} = 80\% \pm 3.5\) points. Typical sizes, in percentage points:
| Questions \(n\) | SE at 50% accuracy | 95% CI half-width | SE at 90% accuracy | 95% CI half-width |
|---|---|---|---|---|
| 100 | 5.0 | ±9.8 | 3.0 | ±5.9 |
| 500 | 2.2 | ±4.4 | 1.3 | ±2.6 |
| 1,000 | 1.6 | ±3.1 | 0.9 | ±1.9 |
| 10,000 | 0.5 | ±1.0 | 0.3 | ±0.6 |
Read the table before reading any leaderboard. On a 500-question benchmark, models a couple of points apart are not distinguishable from a single run, and the order of near neighbours is partly luck:
Better intervals: Wilson and the bootstrap¶
The "\(\hat p \pm 1.96\,\operatorname{SE}\)" interval (the Wald interval) fails when \(n\) is small or \(\hat p\) is near 0 or 1, which is exactly where agent and safety evals often live (a model passes 9 of 10 tasks; a jailbreak succeeds 1 time in 200). For 9/10 the Wald interval is \([0.714, 1.086]\), which includes impossible values above 1. The Wilson score interval (Wilson, 1927) inverts the test instead of plugging in \(\hat p\), and gives \([0.596, 0.982]\). In a simulation with \(n = 20\) and true \(p = 0.9\), the nominal 95% Wald interval actually covers the truth 87.7% of the time; Wilson covers it 95.5% of the time. Use Wilson for proportions.
For anything more complicated than a proportion (a median, an F1 score, a pass@k, a ratio of two metrics, a ranking), use the bootstrap (Efron, 1979): resample the \(n\) items with replacement many times, recompute the metric on each resample, and take the 2.5th and 97.5th percentiles. The idea is to use the empirical distribution as a stand-in for the unknown one. For 400/500 the bootstrap gives \([0.764, 0.834]\), agreeing with Wilson and Wald; for 9/10 it gives \([0.700, 1.000]\) and is too narrow, a reminder that the bootstrap is also an approximation that needs a reasonable \(n\).
Compare models on the same questions, and pair the analysis¶
Two models scored on the same questions are not independent samples. Some questions are hard for both, some easy for both. The right analysis works with the per-question difference \(d_i = b_i - a_i\):
The covariance term is the gift: the more the two models agree on which questions are hard, the smaller the noise in their difference. Miller (2024) reports correlations of 0.3 to 0.7 between frontier models' question-level scores on popular evals, so pairing is a free variance reduction.
The code below simulates 1,000 questions of varying difficulty and two models where B is truly better on every question (true average gain 2.4 points). Observed: A 67.3%, B 71.2%, a gain of 3.9 points, question-level correlation 0.43. Treating the scores as independent samples gives an SE of 2.06 points and \(z = 1.89\), not significant at the 5% level. The paired analysis gives an SE of 1.55 points and \(z = 2.51\), significant. Same data, same models; the paired analysis simply does not throw away the information that the models faced the same questions.
For binary outcomes the paired test has a classical form, McNemar's test (McNemar, 1947): only the discordant questions carry information about which model is better. Here B was right where A was wrong on 141 questions, and the reverse on 102. Under the null hypothesis of no difference these should be equally likely, and \(\chi^2 = (141 - 102)^2 / (141 + 102) = 6.26\) exceeds the 3.84 cut-off. A permutation test reaches the same conclusion without any distributional assumption: under the null, which model got which score on each question is arbitrary, so randomly flip the sign of each \(d_i\) many times and see how often the mean difference is as extreme as observed (\(p = 0.014\)).
What a p-value is, and what it is not¶
A p-value is the probability, assuming the null hypothesis is true, of seeing a result at least as extreme as the one observed. A small p-value says the data would be surprising if there were no effect. It is not the probability that the null is true, not the probability the result will replicate, and not a measure of how large or important the effect is. The American Statistical Association's 2016 statement spells out these misreadings. In practice, report the effect size with its confidence interval ("B beats A by 3.9 points, 95% CI 0.9 to 6.9"), which carries everything the p-value does and more. A 0.3-point gain can be highly significant on a million examples and useless in practice; a 5-point gain can be non-significant on 50 examples and worth investigating.
Power: decide how much data you need before you run¶
Power is the probability that an experiment detects an effect of a given size if it is really there. For a paired comparison with per-question difference standard deviation \(\sigma_d\), detecting a gain \(\delta\) with a two-sided 5% test and 80% power needs about
questions. With \(\sigma_d = 0.49\) (from the simulation) and \(\delta = 2\) points, that is about 4,700 questions, more than most benchmarks have. Many published comparisons are therefore underpowered: they cannot reliably detect the improvements they claim, and the "significant" ones overstate the effect (the winner's curse). Card et al. (2020) document this across NLP. Power analysis also tells you how to spend a budget: more questions, or more samples per question?
More sources of randomness than the questions¶
The question sample is only one source of variance. Others are often larger.
- Sampled answers. With temperature above zero, the same model gives different answers to the same question. By the law of total variance (see probability foundations), total noise is answer noise within questions plus difficulty spread across questions. Sampling each question \(k\) times and averaging shrinks only the first part. For multiple choice without chain of thought, using the model's probability of the correct option removes answer noise entirely (Miller's third recommendation).
- Training seeds and data order. Two training runs differing only in random seed can differ by more than the gain a paper reports. Bouthillier et al. (2021) measure the variance from data splits, initialisation and hyperparameter search; Madaan et al. (2024) quantify seed variance on LLM benchmarks; in deep RL, Henderson et al. (2018) showed that results can flip with the seed, and Agarwal et al. (2021) recommend interquartile means with stratified-bootstrap intervals over few runs.
- Prompt and format. Small changes to the prompt template, answer extraction or few-shot examples move scores by several points. Treat the template as part of the "model" being evaluated, or average over templates.
- Clustered questions. When several questions share one passage, image or task environment, they are not independent; the effective sample size is closer to the number of clusters. Use clustered standard errors; Miller reports clustered SEs on popular evals "over three times as large as naive standard errors". The inflation factor (the design effect) is about \(1 + (m - 1)\rho\) for clusters of size \(m\) with intra-cluster correlation \(\rho\).
Many comparisons, forking paths and test-set reuse¶
Test 20 benchmarks at the 5% level when nothing has changed, and the chance that at least one comes out "significant" is \(1 - 0.95^{20} = 64\%\). The same inflation happens, less visibly, when you try many prompts, checkpoints or hyperparameters and report the best (Gelman and Loken's "garden of forking paths"). Remedies:
- Bonferroni: test each of \(m\) hypotheses at level \(\alpha/m\). Simple and conservative.
- Benjamini–Hochberg (1995): control the false discovery rate, the expected fraction of claimed wins that are false. Sort the \(m\) p-values, find the largest \(k\) with \(p_{(k)} \le k\alpha/m\), and reject the first \(k\). Much more powerful when you expect several real effects.
- Held-out final test sets: select on a development set, then evaluate the single chosen configuration once on a test set that played no part in the choice. Every look at the test set that influences a decision erodes its validity; public benchmarks reused for years become partly overfitted by the field collectively, and contamination makes it worse (see contamination and eval hygiene).
Pairwise preferences: Bradley–Terry and arenas¶
Open-ended outputs often have no single right answer, so evaluation collects pairwise preferences: a human or an LLM judge sees two responses and picks one. The Bradley–Terry model (Bradley and Terry, 1952) gives each model a strength \(s_i\) and says
Fitting it is logistic regression on battle outcomes, and multiplying the strengths by \(400/\ln 10 \approx 174\) puts them on the familiar Elo scale (a 174-point gap means about 73% win probability). Chatbot Arena fits Bradley–Terry to crowd-sourced votes and reports bootstrap confidence intervals on the ratings; the code below does the same for four simulated models and 2,000 battles, recovering strengths within their intervals. The same model is the reward-model loss in RLHF (see reward models): a reward model is a Bradley–Terry model whose strengths are computed by a network from the response.
LLM judges add their own noise and biases (preferring the first-presented or longer answer, or their own model family). Measure the judge like any other instrument: agreement with human labels (Cohen's \(\kappa\), which corrects raw agreement for chance), consistency when the order of the two responses is swapped, and stability across reruns.
Online experiments: A/B tests¶
When a change ships to users, the gold standard is a randomised controlled experiment: randomly assign users to the old or new version and compare a metric. Randomisation makes the two groups comparable in every respect, measured or not, so a difference in outcome can be attributed to the change. The statistics are the same as above (difference in means, SE, CI, power), with three practical traps:
- Peeking. Checking the p-value every day and stopping when it dips below 0.05 inflates the false-positive rate far above 5% (Evan Miller's classic explanation). Fix the sample size in advance, or use a sequential test designed for continuous monitoring.
- Units. Randomise and analyse at the same level. If you randomise users but count messages, heavy users dominate and the SE is too small.
- Novelty and guardrails. Users react to change itself, so effects can fade; and a win on the target metric can hide losses elsewhere (latency, cost, safety), so track guardrail metrics. Kohavi, Tang and Xu's book is the practitioner's reference.
A fixed 50/50 split keeps sending half the traffic to the worse variant until the test ends. When that cost matters (many variants, short-lived content, expensive mistakes), adaptive designs shift traffic towards the better arm as evidence accumulates. Thompson sampling, which keeps a Beta posterior per variant and routes each user by sampling from them, is the standard choice; the price is that adaptively collected data need more care to analyse (see bandits and exploration).
Calibration: are the probabilities honest?¶
A model is calibrated if, among all the times it says 80%, it is right about 80% of the time. Plot a reliability diagram (bin predictions by confidence, plot accuracy against confidence); summarise with the expected calibration error, the average gap weighted by bin size, or with a proper scoring rule such as the Brier score \(\frac1n\sum_i(p_i - y_i)^2\) or log loss (information theory). Modern networks tend to be overconfident (Guo et al., 2017); temperature scaling on a held-out set is the standard fix. Calibration matters whenever a downstream decision uses the probability: abstaining, routing to a human, or cascading to a bigger model.
First principles¶
What "95% confidence" means. It is a property of the procedure, not of one interval: if you repeated the whole experiment many times, 95% of the intervals constructed this way would contain the true value. Any single interval either contains it or does not. (A Bayesian credible interval, from the posterior of estimation, does make a probability statement about the parameter, given a prior; with lots of data and a weak prior the two nearly coincide.)
Why everything scales as \(1/\sqrt n\). A mean of \(n\) independent items has variance \(\sigma^2/n\) (the derivation is on probability foundations). Every method on this page is a way to estimate \(\sigma\) honestly (Wilson near the boundary, clustering when items are not independent, the bootstrap when there is no formula) or to make it smaller (pairing removes shared variance; resampling answers removes within-question variance; probability scores remove sampling noise entirely).
Why pairing works. The difficulty of a question is a nuisance variable that affects both models. Subtracting per question cancels it, exactly as a matched experimental design in medicine compares each patient with themselves. The gain is \(1 - \operatorname{Var}(d)/\operatorname{Var}_\text{unpaired} \approx \rho\), the correlation between the models' per-question scores (for similar variances).
Why the bootstrap works. The sampling distribution of a statistic depends on the unknown population. The empirical distribution of your \(n\) items is the best available estimate of it (it is the nonparametric MLE), so simulate the sampling process from it. This "plug-in" step fails when \(n\) is tiny, when the statistic depends on extreme values (the maximum), or when items are dependent (then resample whole clusters).
Why multiple comparisons are a problem at all. Each test controls its own false-positive rate. Running many and reporting the best changes the question from "is this one effect real?" to "is the largest of many noisy effects real?", and the largest of many noisy numbers is biased upward. The correction is not a technicality; it is answering the question you actually asked.
History¶
From the Guinness brewery to Chatbot Arena
William Sealy Gosset, a chemist at Guinness, published the \(t\)-distribution in 1908 under the pseudonym "Student", for small-sample brewing experiments. Ronald Fisher's Statistical Methods for Research Workers (1925) popularised significance tests and the 5% convention, and his work on agricultural trials introduced randomisation as the basis of causal inference. Jerzy Neyman and Egon Pearson (1933) framed tests as decisions with two error types, the basis of power; Neyman defined confidence intervals in 1937. Edwin Wilson's interval dates from 1927, Quinn McNemar's paired test from 1947 and the Bradley–Terry model from 1952. Bradley Efron's bootstrap (1979) replaced formulas with computation. Yoav Benjamini and Yosef Hochberg introduced the false discovery rate in 1995. In AI, the reproducibility crises in deep RL (2017–2021) and NLP prompted statistical reporting standards, and in 2024 Miller's paper and Chatbot Arena's bootstrapped Bradley–Terry ratings brought them to LLM evaluation.
The maths¶
Estimates and intervals
For i.i.d. scores \(x_1, \dots, x_n\) with mean \(\bar x\) and sample standard deviation \(s\): \(\operatorname{SE} = s/\sqrt n\); the CLT interval is \(\bar x \pm z_{1-\alpha/2}\,\operatorname{SE}\) (use the \(t_{n-1}\) quantile for small \(n\)). For a proportion \(\hat p = k/n\) the Wilson interval is
obtained by solving \(|\hat p - p| \le z\sqrt{p(1-p)/n}\) for \(p\) (a quadratic), i.e. by using the null hypothesis's standard error instead of the estimate's.
Paired comparison and McNemar
\(d_i = b_i - a_i\), \(\bar d = \frac1n\sum_i d_i\), \(\operatorname{SE}(\bar d) = s_d/\sqrt n\) with \(s_d^2 = s_a^2 + s_b^2 - 2 s_{ab}\). Test statistic \(z = \bar d / \operatorname{SE}(\bar d)\).
For binary outcomes, let \(n_{01}\) = number of items with \(a = 0, b = 1\) and \(n_{10}\) the reverse. Under \(H_0: P(a = 0, b = 1) = P(a = 1, b = 0)\), conditional on \(n_{01} + n_{10}\), \(n_{01}\) is binomial with probability \(\tfrac12\), and \(\chi^2 = \frac{(n_{01} - n_{10})^2}{n_{01} + n_{10}}\) is approximately \(\chi^2_1\) (reject at 5% if \(> 3.84\)). For small counts use the exact binomial test.
Clustered standard errors
With items grouped into clusters \(c = 1, \dots, C\), the cluster-robust SE of the mean is
which reduces to the ordinary SE (up to a factor \(\sqrt{(n-1)/n}\)) when every cluster has one item. For equal clusters of size \(m\) with intra-cluster correlation \(\rho\), the variance is inflated by the design effect \(1 + (m - 1)\rho\).
Derivation: the paired-test sample size
Under the alternative, \(\bar d \approx \mathcal{N}(\delta, \sigma_d^2/n)\). A two-sided test rejects when \(|\bar d| > z_{1-\alpha/2}\,\sigma_d/\sqrt n\). Ignoring the far tail, power is \(P\big(\bar d > z_{1-\alpha/2}\,\sigma_d/\sqrt n\big) = \Phi\big(\delta\sqrt n/\sigma_d - z_{1-\alpha/2}\big)\). Setting this to \(1 - \beta\) gives \(\delta\sqrt n/\sigma_d = z_{1-\alpha/2} + z_{1-\beta}\), so
With \(\alpha = 0.05\), \(1 - \beta = 0.8\): \((1.960 + 0.842)^2 = 7.85\). Halving the detectable effect quadruples the sample; pairing helps by shrinking \(\sigma_d^2\).
Benjamini–Hochberg
Given p-values \(p_{(1)} \le \dots \le p_{(m)}\) for \(m\) hypotheses, let \(k = \max\{i : p_{(i)} \le i\alpha/m\}\) and reject hypotheses \(1, \dots, k\). If the tests are independent (or positively dependent), the expected proportion of false rejections among all rejections is at most \(\alpha\,m_0/m \le \alpha\), where \(m_0\) is the number of true nulls.
Bradley–Terry likelihood
For battles \((i_t, j_t, w_t)\) with \(w_t = 1\) if \(i_t\) won,
concave in \(\mathbf{s}\) (it is a logistic regression with design vectors \(\mathbf{e}_{i} - \mathbf{e}_{j}\)). Strengths are identified only up to a common shift, so fix one or add a small L2 penalty. The gradient for model \(k\) is (wins of \(k\)) \(-\) (expected wins of \(k\)), the exponential-family "observed minus expected" of distributions.
Build it¶
Three interval methods, and how often each actually covers the truth:
import numpy as np
rng = np.random.default_rng(0)
z = 1.959964 # 97.5th percentile of N(0, 1)
def wald(k, n):
p = k / n; h = z * np.sqrt(p * (1 - p) / n)
return p - h, p + h
def wilson(k, n):
p = k / n; d = 1 + z**2 / n
c = (p + z**2 / (2 * n)) / d
h = z * np.sqrt(p * (1 - p) / n + z**2 / (4 * n * n)) / d
return c - h, c + h
def bootstrap(k, n, B=20_000):
x = np.r_[np.ones(k), np.zeros(n - k)]
means = x[rng.integers(0, n, size=(B, n))].mean(axis=1)
return np.percentile(means, [2.5, 97.5])
for k, n in [(9, 10), (400, 500)]:
print(f"{k}/{n}: Wald [{wald(k, n)[0]:.3f}, {wald(k, n)[1]:.3f}] "
f"Wilson [{wilson(k, n)[0]:.3f}, {wilson(k, n)[1]:.3f}] "
f"bootstrap [{bootstrap(k, n)[0]:.3f}, {bootstrap(k, n)[1]:.3f}]")
# Coverage: how often does each 95% interval contain the true p? (n = 20, p = 0.9)
p_true, n, trials = 0.9, 20, 20_000
ks = rng.binomial(n, p_true, size=trials)
for name, f in [("Wald", wald), ("Wilson", wilson)]:
lo, hi = f(ks, n)
print(f"{name:>6} coverage at n={n}, p={p_true}: {np.mean((lo <= p_true) & (p_true <= hi)):.3f}")
9/10: Wald [0.714, 1.086] Wilson [0.596, 0.982] bootstrap [0.700, 1.000]
400/500: Wald [0.765, 0.835] Wilson [0.763, 0.833] bootstrap [0.764, 0.834]
Wald coverage at n=20, p=0.9: 0.877
Wilson coverage at n=20, p=0.9: 0.955
Paired versus unpaired comparison, McNemar, a permutation test and a power calculation:
import numpy as np
rng = np.random.default_rng(1)
# 1,000 questions with varying difficulty; model B is slightly better than A on every question
n = 1_000
difficulty = rng.normal(0, 2.5, n)
pA = 1 / (1 + np.exp(-(1.2 - difficulty)))
pB = 1 / (1 + np.exp(-(1.4 - difficulty)))
a = (rng.random(n) < pA).astype(float)
b = (rng.random(n) < pB).astype(float)
d = b - a
print(f"accuracy A {a.mean():.3f} B {b.mean():.3f} difference {d.mean():+.3f} (true expected gain {np.mean(pB - pA):+.3f})")
se_unpaired = np.sqrt(a.var(ddof=1) / n + b.var(ddof=1) / n)
se_paired = d.std(ddof=1) / np.sqrt(n)
print(f"SE of difference: unpaired {se_unpaired:.4f} paired {se_paired:.4f} "
f"corr(A, B) across questions {np.corrcoef(a, b)[0, 1]:.2f}")
print(f"z unpaired {d.mean() / se_unpaired:.2f} z paired {d.mean() / se_paired:.2f}")
# McNemar: only the discordant questions carry information
n01, n10 = int(np.sum((a == 0) & (b == 1))), int(np.sum((a == 1) & (b == 0)))
print(f"B right & A wrong: {n01} A right & B wrong: {n10} McNemar chi2 {(n01 - n10)**2 / (n01 + n10):.2f}")
# Paired permutation (sign-flip) test
flips = rng.choice([-1.0, 1.0], size=(20_000, n))
null = (flips * d).mean(axis=1)
print(f"permutation p-value (two-sided): {np.mean(np.abs(null) >= abs(d.mean())):.4f}")
# Power: questions needed to detect a 2-point gain with 80% power at alpha = 0.05
sd_d, delta = d.std(ddof=1), 0.02
print(f"questions needed (paired, sd of per-question difference {sd_d:.3f}): "
f"{int(np.ceil((1.96 + 0.8416)**2 * sd_d**2 / delta**2))}")
accuracy A 0.673 B 0.712 difference +0.039 (true expected gain +0.024)
SE of difference: unpaired 0.0206 paired 0.0155 corr(A, B) across questions 0.43
z unpaired 1.89 z paired 2.51
B right & A wrong: 141 A right & B wrong: 102 McNemar chi2 6.26
permutation p-value (two-sided): 0.0141
questions needed (paired, sd of per-question difference 0.492): 4744
Notice the observed gain (3.9 points) overshoots the true one (2.4): with this much noise, the experiments that reach significance are disproportionately the ones that got lucky.
A Bradley–Terry fit with bootstrap intervals, the method behind arena leaderboards:
import numpy as np
rng = np.random.default_rng(2)
# Bradley-Terry: P(i beats j) = sigmoid(s_i - s_j). Simulate 2,000 arena battles between 4 models.
true_s = np.array([0.0, 0.3, 0.5, 1.0])
K, N = len(true_s), 2_000
i = rng.integers(0, K, N); j = (i + rng.integers(1, K, N)) % K # random distinct pairs
win = rng.random(N) < 1 / (1 + np.exp(-(true_s[i] - true_s[j]))) # True if i won
def fit_bt(i, j, win, steps=500, lr=2.0):
s = np.zeros(K)
for _ in range(steps): # gradient ascent on the mean log-likelihood
p = 1 / (1 + np.exp(-(s[i] - s[j])))
g = np.zeros(K)
np.add.at(g, i, win - p); np.add.at(g, j, p - win)
s += lr * g / len(i)
s -= s[0] # scores are defined up to a shift: pin model 0 at 0
return s
s_hat = fit_bt(i, j, win)
boot = np.array([fit_bt(i[b], j[b], win[b]) for b in (rng.integers(0, N, N) for _ in range(200))])
lo, hi = np.percentile(boot, [2.5, 97.5], axis=0)
for k in range(K):
print(f"model {k}: true {true_s[k]:.2f} fitted {s_hat[k]:+.2f} 95% CI [{lo[k]:+.2f}, {hi[k]:+.2f}]"
f" Elo-scale {400 / np.log(10) * s_hat[k]:+5.0f}")
model 0: true 0.00 fitted +0.00 95% CI [+0.00, +0.00] Elo-scale +0
model 1: true 0.30 fitted +0.34 95% CI [+0.19, +0.50] Elo-scale +59
model 2: true 0.50 fitted +0.62 95% CI [+0.47, +0.75] Elo-scale +108
model 3: true 1.00 fitted +1.01 95% CI [+0.85, +1.16] Elo-scale +175
Things to try
- Take any eval you run and add a standard error and a paired comparison against the previous version. How many of last month's "wins" survive?
- In the paired simulation, set B equal to A (same logits). Run the experiment 1,000 times and count how often the unpaired and paired tests declare a significant difference. Both should be near 5%. Now report "the best of 20 prompt variants" each time and recount.
- Simulate questions in clusters of 5 that share a difficulty, and compare the naive SE with the clustered SE formula above. How does the ratio change with cluster size?
- Make one model in the Bradley–Terry simulation appear in only 50 battles. What happens to its interval, and how would you decide how many more battles to collect?
Common misconceptions¶
- "If the confidence intervals overlap, the difference is not significant." Overlapping intervals can still hide a significant paired difference; the interval of the difference is what matters, and pairing usually makes it much narrower.
- "p = 0.04 means a 96% chance the effect is real." A p-value is computed assuming no effect; it says nothing directly about the probability of the hypothesis.
- "More decimal places mean more precision." A score of 73.42% on 500 questions has a standard error near 2 points; the last three digits are noise.
- "Temperature 0 makes the eval deterministic." Greedy decoding removes sampling noise but not question-sampling noise, and GPU non-determinism can still change outputs. The SE across questions remains.
Check yourself¶
A model scores 62% on a 250-question benchmark. Give the standard error and a 95% interval.
\(\sqrt{0.62 \times 0.38/250} = 0.0307\), so SE ≈ 3.1 points and the interval is about \(62 \pm 6.0\), i.e. \([56\%, 68\%]\) (Wilson gives almost the same at this \(n\)).
Two models score 80.1% and 81.3% on the same 2,000 questions with a question-level correlation of 0.6. Roughly, is the difference significant?
Each SE is about \(\sqrt{0.8 \times 0.2/2000} = 0.0089\). Unpaired SE of the difference is \(\sqrt2 \times 0.0089 = 0.0126\); with correlation 0.6 the paired SE is \(0.0126\sqrt{1 - 0.6} \approx 0.0080\). The gain of 1.2 points gives \(z \approx 1.5\): not significant at 5%, even with pairing.
Why does McNemar's test ignore questions both models got right or both got wrong?
Those questions are identical under the null and the alternative: they contribute zero to the difference \(\bar d\) and carry no information about which model is better. Only discordant pairs can distinguish the models.
You evaluate 15 prompt variants and the best beats the baseline with p = 0.02. What should you conclude?
Very little. With 15 tries, the chance that at least one reaches \(p < 0.05\) by luck is \(1 - 0.95^{15} \approx 54\%\). Bonferroni would require \(p < 0.05/15 = 0.0033\). The right move is to confirm the chosen variant on fresh, held-out data.
Your agent benchmark has 40 tasks, each graded on 5 sub-questions that share an environment. Why might your error bars be too small, and what is the fix?
The 200 sub-questions are not independent: they share an environment, so outcomes within a task are correlated, and the effective sample size is nearer 40 than 200. Use clustered standard errors with tasks as clusters (or bootstrap whole tasks).
Hard: why can the winner of a leaderboard be expected to perform worse on a fresh test set, even with no contamination?
Selection on noisy scores. The top-ranked model is, on average, the one whose measurement error happened to be most positive (the winner's curse, or regression to the mean). On a new sample the error is fresh, so its expected score falls back towards its true value. The more models compared and the noisier the benchmark, the larger the drop.
Go deeper¶
Papers
- Adding Error Bars to Evals — Evan Miller, 2024. Standard errors, clustering, paired differences and power for LLM evals. The single most useful read for this page.
- The Hitchhiker's Guide to Testing Statistical Significance in NLP — Dror et al., ACL 2018. Which test to use when, and how often NLP papers get it wrong.
- With Little Power Comes Great Responsibility — Card et al., 2020. Power analysis for NLP; many comparisons are underpowered.
- Accounting for Variance in Machine Learning Benchmarks — Bouthillier et al., 2021. Seeds, splits and hyperparameter search as variance sources.
- Deep RL at the Edge of the Statistical Precipice — Agarwal et al., 2021. Few-run evaluation done properly: interquartile mean, stratified bootstrap.
- Chatbot Arena — Chiang et al., 2024. Bradley–Terry ratings from crowd votes, with bootstrap intervals.
- Bootstrap Methods: Another Look at the Jackknife — Efron, 1979. Where the bootstrap began.
- The ASA Statement on p-Values — Wasserstein and Lazar, 2016. Six principles on what p-values do and do not mean.
Videos and lectures
- Bootstrapping Main Ideas — StatQuest. The bootstrap in ten minutes.
- MIT 18.650 Statistics for Applications — Philippe Rigollet, MIT OCW. A rigorous course on estimation, testing and intervals, with video lectures.
Articles
- A statistical approach to model evaluations — Anthropic, 2024. The short version of Miller's five recommendations.
- How Not To Run an A/B Test — Evan Miller. The peeking problem, explained with simulations.
- Seeing Theory — Brown University. Interactive chapters on frequentist inference and regression.
Books
- Trustworthy Online Controlled Experiments — Kohavi, Tang and Xu, 2020. The A/B testing reference from people who ran experiments at Microsoft, Google and LinkedIn.
- An Introduction to Statistical Learning — James, Witten, Hastie and Tibshirani (free PDF). Chapters on resampling methods and multiple testing, with code.
Where this leads¶
- Evals in practice: golden sets and LLM judges — building the eval sets these statistics are applied to.
- Benchmarks and their limits — what the numbers on leaderboards mean, and don't.
- Contamination and evaluation hygiene — when the test set is no longer a fair sample.
- Reward models and preference data — Bradley–Terry as a training objective.
- MLOps: experiments, pipelines, monitoring — running and tracking experiments at scale.