Comparing two agents
Two agents on the same tasks: the paired difference and McNemar's test against the unpaired comparison, the correlation that pairing exploits, and how seeds and repeated runs add or remove variance.
Check yourself ↓ three questions and what to remember, at the end
Loading the animation…
Concept
Most evals end in a comparison: is the new agent better than the old one? The cheapest way to get a sharper answer is not more tasks but a better design: run both agents on the same tasks and compare them task by task.
The reason is that much of the noise in a score is which tasks you drew (chapter 1). When both agents face the same tasks, that noise is shared: an easy draw flatters both, a hard one hurts both, and in the difference it cancels. In the animation, agent A (skill 0.45) and agent B (skill 0.1) run on the same 300 tasks, one run each. A's per-task scores and B's correlate at 0.39. After all 300 tasks, A leads by 7.3 points (the true gap on these tasks is 7.2 points). The paired 95% interval is 1.2% to 13.5% and excludes zero; the unpaired one, the interval you would report if the two had been run on separate task sets, is -0.6% to 15.2% and does not. Same data, a standard error 0.78 times the unpaired one, a different conclusion.
McNemar's test sees the same thing from the tiles. A task both agents pass, or both fail, says nothing about which is better; only the discordant tasks do, where exactly one passes. With one run each, A alone passed 56 tasks and B alone 34. If the agents were equally good, each discordant task would be a coin flip, and a split this uneven or more comes up with probability 0.0263.
Seeds and temperature add a second source of noise: the same agent on the same task does not always do the same thing. The bars under the chart split the variance of the difference into the part from which tasks were drawn and the part from the runs. Unpaired, the tasks account for 32% of that variance; paired, for 0.4%. Pairing removes almost all of the first part; more runs per task shrink the second. Switch to five runs per task and the paired standard error falls from 3.1 points to 2.5 points. Each run costs as much as a new task, so whether to buy runs or tasks depends on which part dominates.
Maths
Write and for the agents' scores on task (a pass, or a mean over runs) and . The difference in mean score is , with standard error . Expanding shows what pairing buys: the covariance, which the unpaired standard error ignores. The engine checks both against scipy's paired and Welch statistics.
For pass/fail outcomes the paired table has four cells; under "no difference" each of the discordant tasks goes either way with probability , so the exact McNemar -value is a two-sided binomial test, with , and the continuity-corrected above approximates it. Planning a paired study needs the discordance and the difference (Connor 1987):
With runs per task and within-task correlation , one task's mean has variance : more runs help only as far as allows, and not at all when .
Code
The paired and unpaired standard errors, cut from the vendored engine (stats.ts):
const seP = Math.sqrt(vd / n);
const seU = Math.sqrt(va / n + vb / n);
const cov = (va + vb - vd) / 2.0;
Check yourself
Commit to an answer before you reveal it: a wrong guess you can explain teaches more than a right one you skimmed. Every number in the answers comes from the same tested model as the chapter’s.
Reveal the answer
Answer: Only the paired one excludes zero
The paired interval is 1.2% to 13.5%; the unpaired one, -0.6% to 15.2%. Same data, a different conclusion: the shared tasks' noise cancels.
Pick one, then reveal.
Reveal the answer
Answer: 0.78 (counted right within 10%)
The agents' per-task scores correlate at 0.39, and pairing subtracts their covariance from the variance of the difference.
Commit to a number, then reveal.
Reveal the answer
Answer: Tasks exactly one agent passes
The discordant ones. Here A alone passed 56 and B alone 34; a split this uneven comes up with probability 0.0263 if they were equal.
Pick one, then reveal.