Comparing Systems with Significance Tests

Deciding whether a difference in effectiveness is real. Why per-query variation dominates, paired tests over topics, the t-test, sign test, Wilcoxon, randomization test, and bootstrap worked step by step on one example they disagree about, a real comparison on Cranfield, how many topics are needed, multiple comparisons, and practical significance.

Two retrieval systems are compared by a paired test over topics, because per-topic differences scatter far less than the scores themselves. For BM25 with and without the Porter stemmer on Cranfield's 225 queries (MAP 0.307 against 0.282), every paired test finds the 0.024 gain significant, with $p$ from 0.0003 to 0.0019; an unpaired t-test gives 0.27. On a ten-topic example built to split them, the five common tests range from $p = 0.0002$ (shifted bootstrap) to 0.109 (sign test). Smucker, Allan and Carterette (2007) recommend the randomization test, with the t-test a close substitute. Topics needed: $n \approx (z_{1-\alpha/2} + z_{1-\beta})^2 (s_d/\delta)^2$, about 158 for the stemmer's effect at 80% power, so 50 topics detect it a third of the time. Many comparisons need a correction such as Bonferroni.

Test collections opened with the question of whether a stemmer improves retrieval. On Cranfield's 225 queries, BM25 with the Porter stemmer reaches a mean average precision of 0.307, and without it 0.282. But average precision varies greatly from query to query. The same system may score 0.9 on an easy query and 0.05 on a hard one, and the difference between two systems is usually much smaller than the difference between queries. A gain of 0.024 may be a real improvement, or an accident of which queries happened to be in the collection.

Significance testing is the standard way to decide between the two. It asks how likely a difference this large would be if the two systems were really equally effective. The general logic of a test, the p-value, and its common misreadings have their home in the statistics course, in Hypothesis Tests for a Mean. This article assumes them and covers what is specific to comparing retrieval systems: the evidence comes in pairs, one pair of scores per topic; topic sets are small; and the scores are bounded and often skewed. The information retrieval course did not cover significance testing, but anyone comparing retrieval systems needs it.

Here is the route. First we see why the topic is the unit of evidence and why the comparison is paired. Then we work five common tests on a small ten-topic example built so that they disagree, and see why they do. Next we return to the stemmer on Cranfield, where the tests agree. Finally we ask how many topics an experiment needs, and what goes wrong when many comparisons are made.

Topics are the unit

The comparison is between two systems run on the same topics, so the evidence is paired. For each topic there is one score for A and one for B, and the quantity of interest is the per-topic difference. Pairing removes the topic-to-topic variation, which dominates the raw scores, and leaves the system-to-system variation. Treating the two systems' scores as independent samples would bury a consistent difference under the variation between topics. (The statistics course derives why pairing removes that variation in the paired samples t-test.)

A small example makes the tests' differences visible. System B has a MAP of 0.470 on ten topics, and system A has 0.434. Here is average precision on each topic:

Topic 1 2 3 4 5 6 7 8 9 10 Mean
System A 0.42 0.31 0.55 0.28 0.61 0.47 0.35 0.52 0.39 0.44 0.434
System B 0.45 0.36 0.54 0.33 0.66 0.49 0.41 0.58 0.37 0.51 0.470
B − A 0.03 0.05 −0.01 0.05 0.05 0.02 0.06 0.06 −0.02 0.07 0.036

B is better on eight topics and worse on two, by small margins. A difference of 0.036 could be a real improvement, or it could be the result of which ten topics happened to be chosen.

Each test starts from a null hypothesis, that the two systems are equally effective so the differences are only noise. It computes a p-value: the probability of a difference at least as large as the one observed if the null hypothesis were true. A small p-value, conventionally below 0.05, is taken as evidence that the difference is real. A p-value is not the probability that the systems are equal, nor a measure of how large the difference is; Hypothesis Tests for a Mean sets out these and the other misreadings.

The paired t-test

The paired t-test treats the differences $d_1, \dots, d_n$ as a sample from a normal distribution and asks whether its mean is zero. The test statistic is

$$t = \frac{\bar{d}}{s_d / \sqrt{n}},$$

where $\bar{d}$ is the mean difference and $s_d$ the standard deviation of the differences. Here $\bar{d} = 0.036$, $s_d = 0.0306$, and $n = 10$:

$$t = \frac{0.036}{0.0306 / \sqrt{10}} = 3.72,$$

with $n - 1 = 9$ degrees of freedom. The two-sided p-value is 0.005. Under the t-test, the improvement is significant.

Stated exactly. The null hypothesis is that the per-topic differences are independent draws from a normal distribution with mean zero. Under it, $t$ follows Student's t distribution with $n - 1$ degrees of freedom, and the two-sided p-value is $P(\lvert T \rvert \ge \lvert t \rvert)$ for $T$ with that distribution. The statistics course derives the test, with its assumptions, in the paired samples t-test.

The calculation step by step

Each step has a reason, so it is worth doing once by hand.

1. The mean difference. $\bar{d} = (0.03 + 0.05 - 0.01 + \dots + 0.07)/10 = 0.36/10 = 0.036$. This is the estimate of how much better B is.

2. How much the differences scatter. Each difference's deviation from the mean, and its square:

Topic 1 2 3 4 5 6 7 8 9 10
$d_i$ 0.03 0.05 −0.01 0.05 0.05 0.02 0.06 0.06 −0.02 0.07
$d_i - \bar{d}$ −0.006 0.014 −0.046 0.014 0.014 −0.016 0.024 0.024 −0.056 0.034
$(d_i - \bar{d})^2 \times 10^4$ 0.36 1.96 21.16 1.96 1.96 2.56 5.76 5.76 31.36 11.56

The squares sum to $84.4 \times 10^{-4} = 0.00844$. The sample variance divides by $n - 1 = 9$ rather than 10, because the deviations are measured from $\bar{d}$, which was fitted to these same ten numbers and so sits closer to them than the true mean would; dividing by 9 corrects that bias, as Confidence Intervals for a Mean derives. So $s_d^2 = 0.00844/9 = 0.000938$ and $s_d = 0.0306$.

3. The standard error of the mean. A mean of $n$ independent differences varies less than one difference does, by a factor of $\sqrt{n}$: $s_d/\sqrt{10} = 0.0306/3.162 = 0.00968$. If the experiment were repeated on ten new topics, $\bar{d}$ would typically land about 0.01 away from where it landed this time.

4. The ratio. $t = 0.036/0.00968 = 3.72$: the observed mean is 3.7 standard errors from zero.

5. The reference distribution. If the true mean difference were zero and the differences normal, $t$ would follow Student's t distribution with 9 degrees of freedom. It has heavier tails than the normal distribution, because $s_d$ is itself an estimate from only ten numbers and is sometimes too small; The Chi-Squared and t Distributions derives it. For a two-sided test at 0.05 the critical value is 2.262 (against 1.96 for the normal). The probability of $|t| \geq 3.72$ is 0.0048. That number is the area in the two tails of the t density beyond $\pm 3.72$, computed by software (the script integrates the density numerically and agrees with scipy). A printed table gives the same verdict without it: the two-sided 0.005 critical value for 9 degrees of freedom is 3.690, and 3.72 lies just beyond it, so $p$ is just under 0.005.

The same numbers give a 95% confidence interval for the true difference, $\bar{d} \pm 2.262 \times 0.00968 = [0.014, 0.058]$. The interval excludes zero exactly when the two-sided test is significant at 0.05. It also says more than the p-value: the data are consistent with an improvement as small as 0.014 or as large as 0.058.

The t-test assumes the differences are roughly normal. Per-topic differences in IR measures often are not, since they are bounded between −1 and 1 and sometimes dominated by a few topics. On TREC runs of fifty topics, Smucker, Allan, and Carterette (2007) found that the t-test's p-values agreed closely with those of the randomization test, which does not assume normality, so at that size the assumption did little harm on their data. With few topics the assumption matters. The next two tests drop it.

The sign test

The sign test ignores how large each difference is and counts only its direction. If the systems were equal, each topic would be equally likely to favor either system. The number of topics favoring B would then follow a binomial distribution with probability 1/2.

Example (eight wins in ten is not enough). B wins 8 of the 10 topics, and under the sign test that is not significant at 0.05. If each topic were a fair coin, the probability of 8 or more wins out of 10 is $(\binom{10}{8} + \binom{10}{9} + \binom{10}{10})/2^{10} = (45 + 10 + 1)/1024 = 56/1024$, and doubling for a two-sided test gives $p = 112/1024 = 0.109$. Under the sign test, the improvement is not significant.

Stated exactly. The null hypothesis is that on each topic a positive and a negative difference are equally likely, independently across topics. Topics with a difference of exactly zero are dropped, leaving $n'$ topics. Under the null hypothesis the number $W$ of positive differences is binomial with $n'$ trials and probability 1/2. With $w$ positive differences observed and $m = \max(w, n' - w)$, the two-sided p-value is $2\,P(W \ge m)$, capped at 1.

The sign test makes no distributional assumption, but it discards the information in the sizes of the differences. A topic B wins by 0.07 counts the same as one it wins by 0.02. With few topics it has little power to detect real differences. The statistics course treats it as an exact binomial test in the sign test and the Wilcoxon signed-rank test.

The Wilcoxon signed-rank test

The Wilcoxon signed-rank test sits between the sign test and the tests that use the raw differences. It replaces each difference by the rank of its absolute size, then gives the rank the difference's sign. The test statistic is the smaller of the two rank sums, the positive and the negative (Smucker, Allan, and Carterette, 2007, §2.2). Tied absolute values share the average of the ranks they span. Working in hundredths:

Topic 3 6 9 1 2 4 5 7 8 10
$\lvert d_i \rvert \times 100$ 1 2 2 3 5 5 5 6 6 7
Rank 1 2.5 2.5 4 6 6 6 8.5 8.5 10
Sign − + − + + + + + + +

The negative ranks are topic 3's 1 and topic 9's 2.5, so $W^- = 3.5$. The positive ranks sum to $W^+ = 55 - 3.5 = 51.5$, since the ranks always total $n(n+1)/2 = 55$. Under the null hypothesis each rank is equally likely to carry either sign. Enumerating all $2^{10} = 1{,}024$ sign patterns, 12 give a smaller rank sum of 3.5 or less. The exact two-sided p-value is therefore $12/1024 = 0.012$.

The 12 patterns can be listed. A negative rank sum of at most 3.5 can be made only from the three smallest ranks, 1 (topic 3), 2.5 (topic 6) and 2.5 (topic 9), since the next rank is 4. The sets of topics given a negative sign are: none (sum 0); topic 3 (sum 1); topic 6 (2.5); topic 9 (2.5); topics 3 and 6 (3.5); topics 3 and 9 (3.5). Topics 6 and 9 together give 5, which is too large. That is six patterns, the observed one among them, and each has a mirror image in which the same topics are the only positive ones, so that the positive rank sum is the small one. Six and six make 12.

The ranks keep the order of the magnitudes but not the magnitudes themselves. Topic 10's difference of 0.07 counts 10, and topic 1's 0.03 counts 4, although one is more than twice the other. The test was devised by Wilcoxon (1945) as a quick approximation that could be tabulated by hand (Smucker, Allan, and Carterette, 2007, §2.2). Its null distribution is the randomization distribution described next, applied to ranks instead of differences. The sign test is the same thing applied to signs alone (§§2.2–2.3).

The randomization test

The randomization test, also called a permutation test, asks directly how unusual the observed difference would be if the labels "A" and "B" were arbitrary. If the systems were equivalent, then on each topic, swapping which score belongs to which system would be equally plausible. A swap flips the sign of that topic's difference. With 10 topics there are $2^{10} = 1{,}024$ ways to assign signs. For each, compute the mean difference, and count how many are at least as extreme as the observed 0.036. In this example, 14 of the 1,024 assignments are, so

$$p = \frac{14}{1024} = 0.014.$$

The improvement is significant, though less decisively than under the t-test.

Stated exactly. The null hypothesis is that, on every topic, the two systems' scores are exchangeable: the pair $(a_i, b_i)$ was as likely to occur as $(b_i, a_i)$, independently across topics. Exchanging a pair turns $d_i$ into $-d_i$, so under the null hypothesis the $2^n$ vectors $(\pm d_1, \dots, \pm d_n)$ are equally likely. The statistic is the mean difference $\bar{d}$, and the two-sided p-value is the fraction of the $2^n$ sign assignments whose mean is at least $\lvert \bar{d} \rvert$ in absolute value, the observed assignment included. No distribution is assumed for the differences. The name recalls experiments in which the experimenter assigns treatments at random, so that the null distribution is created by the assignment itself (Randomized Experiments); in a system comparison the exchangeability is an assumption instead.

For larger topic sets, enumerating every assignment is infeasible, and a random sample of, say, 100,000 assignments is used instead. The observed assignment counts as one of the sample: if $b$ of $B$ sampled assignments are at least as extreme, the p-value is $(b + 1)/(B + 1)$, not $b/B$, which Permutation Tests proves valid at every $B$ (Theorem 6):

import random


def randomization_test(a, b, trials=100_000, seed=0):
    """Two-sided paired randomization test on per-topic scores a and b."""
    rng = random.Random(seed)
    diffs = [y - x for x, y in zip(a, b)]
    observed = abs(sum(diffs) / len(diffs))
    extreme = 0
    for _ in range(trials):
        total = sum(d if rng.random() < 0.5 else -d for d in diffs)
        if abs(total / len(diffs)) >= observed - 1e-12:
            extreme += 1
    return (extreme + 1) / (trials + 1)
The randomization test's null distribution for the ten-topic example: the mean difference for each of the 1,024 ways of assigning signs to the ten differences, each equally likely if the systems are equivalent. Notice that the distribution is symmetric about zero and mostly lies between about -0.03 and +0.03. Only the 14 assignments in the orange tails, 7 on each side, are at least as far from zero as the observed 0.036.
The randomization test's null distribution for the ten-topic example: the mean difference for each of the 1,024 ways of assigning signs to the ten differences, each equally likely if the systems are equivalent. Notice that the distribution is symmetric about zero and mostly lies between about -0.03 and +0.03. Only the 14 assignments in the orange tails, 7 on each side, are at least as far from zero as the observed 0.036.

The 14 extreme assignments come in mirror pairs. The observed assignment itself is one, and flipping every sign gives its mirror image at −0.036. Six more reach at least +0.036:

  • making topic 3, topic 9, or both positive raises the mean to 0.038, 0.040, or 0.042;
  • three further patterns trade one of those gains for a loss elsewhere: topics 6 and 9 flipped (0.036), topics 3, 6 and 9 (0.038), and topics 1, 3 and 9 (0.036).

Each of the seven has a mirror on the negative side, so the two-sided p-value is twice the one-sided $7/1024$.

A Monte Carlo p-value is itself an estimate. With 100,000 samples, 30 runs of the sampled test with different seeds gave a median of 0.0137 and an interquartile range of 0.0135 to 0.0140, around the exact 0.0137. (These were computed with numpy's generator in tools/experiments/cranfield/significance.py; the code above with seed 0 gives 0.0146.) The sampling error, a few ten-thousandths, is negligible for deciding at 0.05. It should be kept in mind when a p-value is reported to four places.

What the test responds to

The randomization test looks at the consistency of a difference, not only its mean.

Example (the whole gain on one topic). Suppose the whole 0.36 of total improvement came from one topic: nine differences of zero and one of 0.36. The mean difference is the same 0.036, and the randomization test's p-value is now 1. Every sign assignment gives a mean of either +0.036 or −0.036, so all 1,024 are as extreme as the observed one. The t-test gives $p = 0.34$. One topic carrying the whole gain is no evidence that the next topic will show any gain, and both tests say so.

The bootstrap

The bootstrap takes a different route to the same question (the library's bootstrap method page treats it in general, and Paired Comparisons of Models applies the paired bootstrap to model evaluations). It treats the ten topics as a sample from a population of possible topics. It imitates drawing new samples by resampling the ten observed differences with replacement: a bootstrap sample of ten might contain topic 7 three times and topic 3 not at all. Repeating this many times, and computing the mean difference of each resample, gives the bootstrap distribution of the mean.

Two things are read from it:

  • A confidence interval. The 2.5th and 97.5th percentiles of 100,000 resampled means are 0.017 and 0.053 (identical to three decimals over 30 seeds). This is the percentile interval, the bootstrap's counterpart of the t interval [0.014, 0.058], and here it is narrower.
  • A p-value by the shift method (Smucker, Allan, and Carterette, 2007, §2.4). The bootstrap distribution is centered on the observed mean, not on zero. The shift method moves it to have mean zero, takes that as the null distribution, and counts the resampled means at least 0.036 from zero. Here that gives $p = 0.00016$ (median of 30 seeds; IQR 0.00014 to 0.00019). That is almost a hundred times smaller than the randomization test's 0.014.
Two null distributions for the same ten differences, both drawn as probability densities so their heights can be compared. Bars: the randomization distribution. Line: the shifted bootstrap distribution from 2,000 resamples. Notice that the bootstrap is visibly narrower and taller. The dashed lines mark the observed difference of plus or minus 0.036; the randomization distribution still has a little mass beyond them, the bootstrap almost none.
Two null distributions for the same ten differences, both drawn as probability densities so their heights can be compared. Bars: the randomization distribution. Line: the shifted bootstrap distribution from 2,000 resamples. Notice that the bootstrap is visibly narrower and taller. The dashed lines mark the observed difference of plus or minus 0.036; the randomization distribution still has a little mass beyond them, the bootstrap almost none.

Why the two null distributions differ

Here is the reason for the difference in one sentence: flipping signs leaves the observed effect inside the null distribution's spread, while shifting the bootstrap removes it. The spreads can be computed exactly.

Flipping signs at random gives each difference a mean of zero and a variance of $d_i^2$. So the randomization distribution of $\bar{d}$ has variance $\sum d_i^2 / n^2$. Resampling with replacement draws from the ten values with variance $\sum (d_i - \bar{d})^2 / n$, so the bootstrap mean has variance $\sum (d_i - \bar{d})^2 / n^2$. Since $\sum d_i^2 = \sum (d_i - \bar{d})^2 + n\bar{d}^2$, the randomization null is wider by exactly the term that the observed effect contributes. The two standard deviations are

$$\sqrt{0.0214}/10 = 0.0146 \quad \text{versus} \quad \sqrt{0.00844}/10 = 0.0092.$$

With a consistent effect and only ten topics, that term is a large part of the total. The shifted bootstrap then reports far more confidence than the data justify. With many topics and a small effect relative to the scatter, $n\bar{d}^2$ is small beside $\sum(d_i - \bar{d})^2$ and the two agree. That is what Smucker, Allan, and Carterette found on TREC runs of 50 topics. They also noted a small systematic tendency of the bootstrap toward smaller p-values (§4). The bootstrap is a large-sample method, and ten topics is not a large sample. The Plug-In Principle explains why: the bootstrap replaces the population of topics by the empirical distribution of the observed ones, and it proves the exact bootstrap variance used above and the conditions under which the method is consistent as the sample grows.

Why the tests disagree

Test Uses p-value Significant at 0.05?
Paired t-test magnitudes, assumes normality 0.005 yes
Randomization test magnitudes, exact 0.014 yes
Wilcoxon signed-rank ranks of magnitudes 0.012 yes
Bootstrap, shift method magnitudes, resampled 0.0002 yes
Sign test directions only 0.109 no

The tests use different information and make different assumptions:

  • the sign test uses only directions;
  • the t-test uses magnitudes and assumes normality;
  • the randomization test uses magnitudes and assumes only that the labels are exchangeable under the null hypothesis;
  • the Wilcoxon test uses the order of the magnitudes;
  • the bootstrap assumes the topics are a random sample from a population that the observed ten represent well.

Smucker, Allan, and Carterette (2007) compared tests on TREC data. They found that the t-test, the randomization test, and the bootstrap generally agreed with one another, while the sign test and the Wilcoxon signed-rank test often gave different answers. They recommended the randomization test, noted that the t-test led to the same conclusions on their data, and advised against the sign and Wilcoxon tests for comparing IR systems.

The ten-topic example was built to make the tests disagree. On a real comparison with a reasonable number of topics they mostly agree, as the next section shows.

A real comparison: does stemming help on Cranfield?

Back to the stemmer. It does help, and every paired test says so. The two systems are BM25 ($k_1 = 1.2$, $b = 0.75$) with and without the Porter stemmer, run on all 225 Cranfield queries and scored by average precision (script tools/experiments/cranfield/significance.py). On a real comparison like this the tests usually agree, and the reason for pairing becomes visible.

Left: each query's average precision without stemming (horizontal) and with it (vertical). Notice that the points spread along the whole diagonal, from near 0 to 1, because queries differ greatly in difficulty. Right: the per-query differences, sorted. Most are small, 129 queries gain and 83 lose, and a few large gains and losses dominate the tails. The mean difference, +0.024, is the dashed line.
Left: each query's average precision without stemming (horizontal) and with it (vertical). Notice that the points spread along the whole diagonal, from near 0 to 1, because queries differ greatly in difficulty. Right: the per-query differences, sorted. Most are small, 129 queries gain and 83 lose, and a few large gains and losses dominate the tails. The mean difference, +0.024, is the dashed line.

The left panel shows why pairing matters. Average precision ranges from near 0 to 1 across queries, with a standard deviation of about 0.23 for either system. The differences, in the right panel, have a standard deviation of 0.109, less than half as much, because a query that is hard for one system is hard for the other. The mean difference is 0.024 (MAP 0.307 against 0.282).

Example (the same data, unpaired). If the pairing is ignored, and the two systems' 225 scores are compared as two independent samples, the difference is no longer significant, as the last row of the table shows:

Test Statistic Two-sided p
Paired t-test $t = 0.0243/(0.1093/\sqrt{225}) = 3.34$, 224 df 0.0010
Randomization (20,000 samples, 30 seeds) mean difference 0.0243 0.0007 (IQR 0.0006 to 0.0008)
Bootstrap, shift method (20,000 samples, 30 seeds) mean difference 0.0243 0.0011 (IQR 0.0009 to 0.0012)
Wilcoxon signed-rank (13 zero differences dropped) rank sums 0.0003
Sign test 129 wins, 83 losses, 13 ties 0.0019
Unpaired t-test (wrongly ignoring the pairing) $t = 1.11$ 0.27

Every paired test finds the improvement significant, and the three that use the magnitudes agree closely, as Smucker, Allan, and Carterette (2007) found on TREC. The 95% intervals agree too: the t interval is [0.010, 0.039] and the bootstrap percentile interval [0.010, 0.039].

The last row is the mistake that pairing prevents. Treated as two independent samples of 225 scores, the same data give $p = 0.27$. The unpaired statistic divides the same difference of means by a standard error built from the two systems' own standard deviations, 0.239 with stemming and 0.228 without (the statistics course derives it in the two-sample t-test):

$$t = \frac{0.02434}{\sqrt{\dfrac{0.2394^2}{225} + \dfrac{0.2277^2}{225}}} = \frac{0.02434}{0.02203} = 1.105,$$

which the table rounds to 1.11 (1.1051 before rounding; with the inputs cut to three figures the quotient would come out as 1.10).

The comparison is then made against the scatter between queries, 0.23, instead of the scatter of the differences, 0.11. The paired standard error is $0.1093/\sqrt{225} = 0.0073$, a third of the unpaired 0.0220, and that factor of three is the whole difference between $t = 3.34$ and $t = 1.11$.

The size of the effect, the mean difference divided by the standard deviation of the differences, is $0.0243/0.1093 = 0.22$. Unlike the p-value, it does not grow with the number of topics. It determines how many topics are needed to see the difference reliably, which is the next question.

How many topics?

Fewer topics mean noisier comparisons. Voorhees and Buckley (2002) estimated, from TREC data, how often a conclusion that one system beats another would reverse on a different set of topics of the same size. They computed these error rates directly for topic sets of up to 25 topics and extrapolated to larger sets, and reported that the rates were larger than anticipated. Their conclusion was that researchers need to take care in concluding that one method is better than another, especially when few topics are used. Small topic sets can show a significant difference, as the ten-topic example does, but small effects measured on them are fragile.

Sakai (2016) reviewed a decade of papers in SIGIR and TOIS and found that many reported too little to assess their tests. Among those that could be assessed, some experiments were far too small to detect real differences. Others were so large that trivially small differences became significant. Sakai recommended reporting effect sizes alongside p-values and choosing sample sizes in advance from the effect sizes found in earlier studies.

Subsets of Cranfield

Cranfield's 225 queries allow a direct look at what smaller topic sets would have shown. For three comparisons with different true differences, the script draws random subsets of $n$ queries (300 subsets for each size, repeated over 30 seeds; medians reported). It records two things:

  • how often the subset shows the opposite sign to the full set;
  • how often a paired t-test on the subset finds a significant difference in the right direction. This is the power of the experiment.

Example (fifty topics detect the stemmer one time in three). The stemming improvement is significant on all 225 queries ($p = 0.001$). An experiment with the conventional 50 topics, drawn from the same queries, detects it only 32 percent of the time:

Queries Stemming: wrong sign Stemming: detected TF-IDF vs BIM: wrong sign TF-IDF vs BIM: detected
10 23% 6% 5% 28%
25 12% 15% 0.3% 67%
50 3% 32% 0% 94%
100 0% 66% 0% 100%
Left: how often a random subset of Cranfield queries gets the direction of a difference wrong, for three comparisons. Right: how often a paired t-test on the subset detects the difference. Notice that for stemming (a MAP gain of 0.024), 25 queries get the direction wrong about one time in nine and detect it about one time in seven, while 100 queries detect it two times in three. For TF-IDF against BIM (0.074), 50 queries almost always suffice. For keeping stop words (0.001, not significant even on all 225 queries) more queries do not help.
Left: how often a random subset of Cranfield queries gets the direction of a difference wrong, for three comparisons. Right: how often a paired t-test on the subset detects the difference. Notice that for stemming (a MAP gain of 0.024), 25 queries get the direction wrong about one time in nine and detect it about one time in seven, while 100 queries detect it two times in three. For TF-IDF against BIM (0.074), 50 queries almost always suffice. For keeping stop words (0.001, not significant even on all 225 queries) more queries do not help.

The subsets are drawn from a fixed pool of 225, so at 100 queries they share much of their content with the full set and the power is slightly overstated. For truly new topics the normal approximation below gives 60 percent at 100 rather than 66.

Planning the number of topics

The power can be planned, as Power Analysis for Evaluations does for model evaluations. The formula is the sample-size formula for a test of a mean, which Power and Sample Size for a Test of a Mean derives from the power function; here the "observations" are topics. In short, a two-sided test at level $\alpha$ detects a true mean difference $\delta$ with probability $1 - \beta$ when $\delta$ is $z_{1-\alpha/2} + z_{1-\beta}$ standard errors from zero. The standard error is $s_d/\sqrt{n}$, so solving for $n$:

$$n \approx (z_{1-\alpha/2} + z_{1-\beta})^2 \left(\frac{s_d}{\delta}\right)^2.$$

For $\alpha = 0.05$ and 80% power, $(1.960 + 0.842)^2 = 7.85$. With the stemming numbers, $s_d/\delta = 0.1093/0.0243 = 4.49$, so $n \approx 7.85 \times 20.2 \approx 158$ topics. (With the unrounded inputs, $s_d = 0.10933$ and $\delta = 0.02434$, the script gives 158.4; with the four-figure values printed here the product is 158.8.) That is the calculation Sakai recommends making before an experiment, with $s_d$ and $\delta$ taken from earlier work. It says that a collection of 50 topics is too small for an effect of this size, whatever the p-value of a particular run turns out to be. The same formula, applied to users instead of topics, sizes online experiments, and evaluating embedding models applies it to comparisons of embedding models with BM25 on Cranfield.

Pitfalls

Multiple comparisons. Testing twenty variants against a baseline at the 0.05 level will, on average, find one "significant" difference even if none is real. When many comparisons are made, the threshold must be adjusted. The Bonferroni correction divides the significance level by the number of comparisons; other methods are designed for comparing many systems at once (Carterette, 2012), and Comparing Systems Across Many Tasks compares many systems at once with Friedman's test. When finding several real improvements matters more than avoiding every false one, the false discovery rate is a weaker standard that keeps more power.

Example (twenty useless variants). If none of twenty variants truly differs from the baseline, and each is tested independently at 0.05, the chance that at least one appears significant is about 64 percent. Each test avoids a false alarm with probability $0.95$, so the chance that at least one of $m$ raises a false alarm, the family-wise error rate, is $1 - 0.95^m$: 0.40 for ten variants, 0.64 for twenty. The Bonferroni correction tests each variant at $0.05/m$. The chance that at least one of several events happens is never more than the sum of their chances, so the family-wise rate is then at most $m \times 0.05/m = 0.05$, whether or not the tests are independent. Multiple Comparisons and the Bonferroni Correction proves this and gives sharper procedures, such as Holm's, which Closed Testing derives from a general principle.

The chance that at least one of m useless variants appears significantly different from a baseline, in a simulation on Cranfield's per-query differences. Notice that testing each at 0.05 (orange points), the chance follows the curve 1 minus 0.95 to the power m and passes 60 percent at twenty variants. With the Bonferroni correction (blue), it stays at or below 5 percent.
The chance that at least one of m useless variants appears significantly different from a baseline, in a simulation on Cranfield's per-query differences. Notice that testing each at 0.05 (orange points), the chance follows the curve 1 minus 0.95 to the power m and passes 60 percent at twenty variants. With the Bonferroni correction (blue), it stays at or below 5 percent.

The simulation behind the figure builds variants that are truly no better than BM25. For each query, a variant's score differs from BM25's by the size of the real stemming difference on that query, with a random sign. Each variant is then compared with BM25 by a paired t-test on the 225 queries, 1,000 times for each $m$ and over 30 seeds. With twenty variants, at least one was "significant" in 63 percent of experiments (theory: 64 percent); with Bonferroni, in 3.8 percent. The price of the correction is power. A real improvement must now clear $0.05/20 = 0.0025$, which for the stemming effect needs about 300 topics rather than 158 by the formula above.

Statistical versus practical significance. With enough topics, a tiny difference becomes statistically significant without being worth anything to users. A p-value says whether a difference is likely real, not whether it matters. Reporting the size of the difference, ideally with a confidence interval, answers the second question.

Reusing the test set. A significance test assumes the test topics were not used to develop the system. Tuning on the test topics, discussed in test collections, invalidates the test however small the p-value.

Choosing the test after seeing the result. Running several tests and reporting the one that gives significance inflates the error rate just as multiple comparisons do; Type I and Type II Errors measures how much related practices, such as stopping when the result looks good, raise the error rate. The test should be chosen in advance; Selective Inference and the Garden of Forking Paths shows what can still be done with a result chosen after looking.

Worked problems

The course text has no exercises on significance testing, so the problems below are posed on this article's own data and on one further small example, chosen so that each test is worked once more. The numbers are recomputed in tools/experiments/eval_measures/worked_examples.py, which enumerates the exact null distributions.

Problem 1 (nine small gains and one large loss). On ten topics, system B beats system A by 0.01 in average precision on nine topics and loses by 0.20 on the tenth. Apply the sign test, the paired t-test, the randomization test and the Wilcoxon signed-rank test, two-sided, and say what each concludes.

Solution. The sign test finds B significantly better ($p = 0.021$); the t-test and the randomization test find no difference ($p = 0.61$ and $p = 1$), with a mean that favors A; the Wilcoxon test is in between ($p = 0.092$).

Sign test. Nine positive differences of ten, none zero. $P(W \ge 9) = (\binom{10}{9} + \binom{10}{10})/1024 = 11/1024$, so $p = 22/1024 = 0.021$.

Paired t-test. The mean difference is $(9 \times 0.01 - 0.20)/10 = -0.011$: on average B is worse. The deviations from the mean are $0.021$ nine times and $-0.189$ once, so the sum of squares is $9(0.000441) + 0.035721 = 0.03969$, $s_d^2 = 0.03969/9 = 0.00441$ and $s_d = 0.0664$. The standard error is $0.0664/\sqrt{10} = 0.0210$ and $t = -0.011/0.0210 = -0.524$, with 9 degrees of freedom: $p = 0.61$. The 95% interval is $-0.011 \pm 2.262 \times 0.0210 = [-0.059, 0.037]$.

Randomization test. The observed total is $-0.11$. Under any assignment of signs the total is $\pm 0.20$ plus a sum of nine terms $\pm 0.01$, which lies between $-0.09$ and $0.09$, so its absolute value is at least $0.20 - 0.09 = 0.11$. Every one of the 1,024 assignments is at least as extreme as the observed one, and $p = 1$.

Wilcoxon. The nine differences of size 0.01 tie for ranks 1 to 9 and each gets the average, 5; the difference of size 0.20 gets rank 10. So $W^- = 10$ and $W^+ = 45$. The patterns with a negative rank sum of at most 10 are: no negative sign (1 pattern), one small difference negative (9 patterns, sum 5), two small differences negative ($\binom{9}{2} = 36$ patterns, sum 10), and the large difference alone negative (1 pattern, sum 10): 47 patterns. With their mirror images, $94/1024 = 0.092$.

The tests disagree here about the direction as well as the significance, and each is answering its own question correctly. B wins on most topics, which is what the sign test measures. B loses on average, because one loss outweighs nine wins, which is what the mean measures. This is the case against the sign test for comparing systems by a mean such as MAP: it can declare the system with the lower MAP significantly better.

Problem 2 (the sign test on Cranfield). With stemming, BM25 gains on 129 Cranfield queries, loses on 83 and ties on 13. Compute the sign test's two-sided p-value, and compare it with a normal approximation.

Solution. $p = 0.0019$. The 13 ties are dropped, leaving $n' = 212$ queries, of which 129 are wins. Under the null hypothesis the number of wins is binomial with 212 trials and probability 1/2, so it has mean 106 and standard deviation $\sqrt{212}/2 = 7.28$. The exact tail, summed by the script, gives $2\,P(W \ge 129) = 0.0019$. The normal approximation with a continuity correction gives $z = (128.5 - 106)/7.28 = 3.09$, and a two-sided tail of 0.0020, close to the exact value. The sign test's p-value is larger than the paired t-test's 0.0010, and both are far below 0.05.

Problem 3 (how many topics for a larger effect). TF-IDF beats the binary independence model on Cranfield by a mean of 0.0737 in average precision, with a standard deviation of the per-query differences of 0.1579. Find the number of topics that gives 80 percent power at the 0.05 level, and compare it with the simulation's table.

Solution. About 36 topics. The effect size is $0.0737/0.1579 = 0.467$, so $s_d/\delta = 2.14$ and

$$n \approx 7.85 \times 2.14^2 = 7.85 \times 4.59 = 36.0.$$

The subset simulation above agrees: with 25 queries the difference was detected 67 percent of the time, and with 50 queries 94 percent, so 80 percent falls between them. The stemming effect, at an effect size of 0.22, needed 158 topics. Halving the effect size roughly quadruples the topics, since $n$ grows with the inverse square of the effect size: $(0.467/0.223)^2 = 4.4$ and $158/36 = 4.4$.

Problem 4 (five variants). Five variants of a system are each compared with the baseline at the 0.05 level, and none truly differs from it. Find the chance of at least one significant result if the tests are independent, and the level each test must use under the Bonferroni correction.

Solution. The chance is $1 - 0.95^5 = 0.226$, and the corrected level is $0.05/5 = 0.01$. Each test is silent with probability 0.95, and five independent tests are all silent with probability $0.95^5 = 0.774$. With each test at 0.01, the chance of at least one false alarm is at most $5 \times 0.01 = 0.05$, by the bound on the probability of a union stated above, whether or not the tests are independent. For independent tests it is $1 - 0.99^5 = 0.049$.

What we have learned

A comparison of two retrieval systems is paired over topics, and pairing is what makes small differences visible. On Cranfield's stemmer comparison the paired tests give p-values between 0.0003 and 0.0019, while the unpaired test gives 0.27. On the ten-topic example the five tests disagree, from 0.0002 for the shifted bootstrap to 0.109 for the sign test. Smucker, Allan, and Carterette recommend the randomization test, with the t-test as a close substitute. A 0.024 gain needs about 158 topics for 80 percent power, so the conventional 50 detect it only about a third of the time. Many comparisons call for a correction such as Bonferroni.

The same paired design applies wherever two systems are scored on the same items. The library's statistical approach to model evaluations applies it to language models scored on the same questions.

Every comparison so far has used assessors' judgments on a fixed set of topics. A search engine with millions of users can instead watch how people respond to its results. The next article, Online Evaluation, shows how that is done fairly and how many users it needs.

References

  • Carterette, B. (2012). Multiple testing in statistical analysis of systems-based information retrieval experiments. ACM Transactions on Information Systems, 30(1), article 4. record
  • Sakai, T. (2016). Statistical significance, power, and sample sizes: A systematic review of SIGIR and TOIS, 2006–2015. In Proceedings of SIGIR 2016, 5–14. record · 2 pages
  • Smucker, M. D., Allan, J., and Carterette, B. (2007). A comparison of statistical significance tests for information retrieval evaluation. In Proceedings of CIKM 2007, 623–632. record
  • Voorhees, E. M., and Buckley, C. (2002). The effect of topic set size on retrieval experiment error. In Proceedings of SIGIR 2002, 316–323. record
  • Wilcoxon, F. (1945). Individual comparisons by ranking methods. Biometrics Bulletin, 1(6), 80–83. record · 6 pages

Reviewed: verified, 16 Nov 2026 · citations checked, 16 Nov 2026 · editorial review, 23 Nov 2026 · 15 revisions