Tool

Sample size and error bars

Every score on a test set is an estimate. How far it could move if you had drawn different items depends mostly on how many items you used. This page shows how to put numbers on that, and how many items you need before a comparison means anything.

The short version

Interval by test-set size

Wilson 95% interval, in percentage points either side of the observed accuracy, by number of items
Items (n)Observed accuracy 50%: points either sideObserved accuracy 90%: points below / above
50±13.4−11.4 / +5.7
100±9.6−7.4 / +4.5
200±6.9−4.9 / +3.4
500±4.4−2.9 / +2.3
1,000±3.1−2.0 / +1.7
5,000±1.4−0.9 / +0.8

These are Wilson 95% intervals, in percentage points. At 50% the interval is symmetric and is the widest it gets, so the first column is the worst case. Near 0% or 100% it is not symmetric, so the second column gives the points below and above 90%. For example, 45 correct out of 50 gives 78.6% to 95.7%, not a symmetric ± figure. The usual symmetric formula, 1.96 × √(p(1−p)/n), is too narrow there. Assumes independent items scored right or wrong, so the intervals cover which items were drawn and nothing else.

Calculators

These run in your browser and send nothing anywhere. They give planning figures from standard formulas, listed under Sources; read the assumptions before relying on them.

1. How precise is my score?

Enter the number of items and the accuracy you observed. You get a Wilson interval at the confidence level you choose.

The calculator needs JavaScript. The table and worked examples on this page work without it.

2. How many items for a target margin of error?

Planning figure for a score you have not collected yet. If you have no idea of the accuracy, use 50, which is the most cautious.

The calculator needs JavaScript. The table and worked examples on this page work without it.

3a. Compare two systems on different items

Use this when the two systems are scored on separate samples of items, for example two groups of real users.

The calculator needs JavaScript. The table and worked examples on this page work without it.

3b. Compare two systems on the same items

Use this when you run both systems on one test set. It depends on how often they disagree.

The calculator needs JavaScript. The table and worked examples on this page work without it.

4. Did system A really beat system B on the same items?

After the run, count the items where only A was right and where only B was right. You get the difference and its confidence interval.

The calculator needs JavaScript. The table and worked examples on this page work without it.

Worked examples

The main figures on this page are generated from build/sample_stats.py and checked by build/test_sample_size.py in the site repository. That test reads the built page and checks every number in the interval table, the short version, and these worked examples against separate calculations, including exact power for the sample-size figures. It does not check the wording of the assumptions below or the sources, and it checks formulas, not whether they suit your data.

What the numbers assume, and where they fail

For real examples, see the case studies. For a reporting layout that includes intervals, see the results template.

Sources

The formulas in the calculators are standard textbook results; this page applies them to eval data and does not add to them. The sample-size formulas in 3a and 3b are normal approximations. Figures for an exact test, and the pilot ranges, are computed on this site by enumerating the exact distributions and applying the Wilson interval; they are not from the sources above. Miller’s worked example for detecting a 3-point difference, under the assumptions in his paper, comes to roughly 1,000 questions.

Planning aid, not a statistical consultation. For a high-stakes decision, have someone with statistics training check the design. The figures in the table and worked examples are checked by build/test_sample_size.py in the site repository.