published · 3 min read

Two Standard Errors on a Median Let Through 12% at n=2

climb kept a change when its gain beat 2·1.2533·sd/√n from a few pairs. With nothing changed at all and a 5% spread in the gains, that rule kept more than one run in ten at two pairs.

Bar chart of false keeps with no real change, by pairs measured: the old two-standard-errors rule falls from 11.6% at n=2 to 2.6% at n=12, the t rule stays between 1.4% and 2.1%, against a dashed 2.5% line.
The post's table as a chart: how often each rule keeps a change that did nothing.

An AI agent drafted this from my projects, agents ran the measurements, and another agent checked the draft claim by claim against the code and the run records or briefs that were kept. The projects and opinions are mine.

climb is my plugin that measures what coding agents change, and decides whether to keep a change. With nothing changed at all and a 5% spread in the gains, its old keep rule still said yes 11.6% of the time at two pairs. For a close call it runs base and candidate back to back a few times and looks at the gains, and a gain had to clear this bar.

noise: Math.max(0.01, (2 * 1.2533 * sd) / Math.sqrt(n))

That 2 is the usual two standard errors, 1.2533 is the large-sample price of a median, and n was 2 to 4 pairs. That 11.6% is per metric and per decision: climb keeps a change when any non-hold metric clears its bar and none regresses, so two independent unchanged metrics at two pairs would keep about 19%. Both versions of pairedVerdict, from before the fix and from the current code, got 200,000 simulated runs per row on bun 1.3.14, seeded, with gains drawn from a normal with mean 0 and a 5% spread, and an agent cut them out of git and ran them.

These percentages are false-keep rates.

n=2   old rule  11.6%   t rule  1.9%
n=3   old rule   7.1%   t rule  1.7%
n=4   old rule   4.8%   t rule  1.5%
n=6   old rule   3.4%   t rule  1.4%
n=8   old rule   2.9%   t rule  1.5%
n=12  old rule   2.6%   t rule  2.1%

Only a gain above the bar counts as a keep, so the design is 2.3% for a 2 when the spread is known and 2.5% for t's 97.5th percentile when it's estimated. A 2 works when you already know the spread. Here sd comes from the two to four gains being judged. If two gains land close together by luck, sd comes out tiny and a small median clears the bar. Student's t exists for this case, and with one degree of freedom its 97.5th percentile is 12.71. At two pairs a median is also a mean, so you can work out the odds by hand, and 1.2533 has nothing to pay for there: the bar is 2.5 standard errors of that mean, and a bare 2 with no floor would keep 14.76%. In that line there is a 1% floor. Without it the old rule keeps 12.08% of the time, and the floor brings that down to 11.6 at this spread.

t975 replaced the 2.

export const t975 = (dof: number) => [Number.POSITIVE_INFINITY, 12.71, 4.3, 3.18, 2.78, 2.57, 2.45, 2.36, 2.31, 2.26, 2.23][dof] ?? 2.1;
noise: Math.max(0.01, (t975(n - 1) * 1.2533 * sd) / Math.sqrt(n))

The t rule errs the other way, at 1.4 to 1.9% for two to eight pairs: t is exact for a mean, and 1.2533 overcharges a median of three to eight gains, which is only about 1.1 to 1.2 times noisier than their mean. The price is missed gains: a real 5% gain was kept about 13% of the time at three pairs under the t rule, against 41% under the old one; an exact t test on the mean kept 18%.

Those rows assume normal gains and a fixed pair count, and real benchmarks promise neither. Heavier symmetric tails lowered both rules' false keeps in the simulation; skewed gains are the open risk. With fewer than six pairs no distribution-free test of the paired gains can call a gain at 2.5% (a sign test's smallest one-sided p is 1/2ⁿ), so at three to five pairs any bar leans on an assumed shape. climb 0.4.7 stops at three pairs when a result is clear and runs to six when it's close, which this simulation didn't model. Plain comparisons weren't part of this fix either: noiseFromSd still multiplies by 2, and a result between one and two times that noise gets sent to pairs.

As for how long it mattered, that rule lasted under an hour. Paired measurement and the fix from an independent review both landed on 29 October under my git name, though session logs show agents wrote all 131 of climb's commits. I don't know how many changes it kept in that hour. That review put it at "5-12% false keeps against a ~2% design", and the fix also raised the minimum to three pairs, so climb no longer plans a two-pair call.