ML0152 Permutation Test vs Bootstrap

When do you reach for a permutation test instead of a bootstrap? Explain what each estimates (null distribution vs sampling distribution) and why they answer different questions.

Three-panel scenario card with dashed borders. Panel one, the randomized pilot: the old ranker A has 30 users with mean 21.4 minutes of watch time per day, the new ranker B has 30 users with mean 24.6 minutes and an observed gap of plus 3.2 minutes; users were assigned by coin flip and per-user watch time is right-skewed. Panel two, two questions from the PM: Q1 asks whether coin-flip assignment alone could produce a gap as large as 3.2 minutes, Q2 asks how large the true lift is and what a 95 percent range for it is. Panel three, two resampling scripts: script P shuffles the 60 labels and recomputes the gap 10,000 times, script B resamples each arm with replacement 10,000 times, followed by the open question of which script answers which question

The Problem: A 60-user pilot randomized 30 users to the old ranker and 30 to the new one, and the new ranker shows a 3.2-minute lift in daily watch time (21.4 vs 24.6 minutes). The PM wants to know whether the gap is more than coin-flip noise and how large the true lift is, and the analyst has two resampling scripts but must decide which one answers which question.

Answer

Reach for a permutation test when the question is whether an effect exists at all, and reach for a bootstrap when the question is how large the effect is and how precisely you know it. A permutation test shuffles group labels, which is legitimate only if the labels are exchangeable under the null, so it builds the null distribution of the statistic you would see if the treatment did nothing. A bootstrap resamples the observed units with replacement within each group, so it approximates the sampling distribution of the estimate around the true value and yields standard errors and confidence intervals. The permutation test is Fisher’s randomization inference. When treatment was randomly assigned, its p-value is exact at any sample size and for any outcome distribution. The bootstrap is a large-sample plug-in approximation that needs a moderate n, but it answers the question about magnitude that a p-value never does.

(1) Different Questions: The permutation test computes P(|T| \geq |t_{\mathrm{obs}}| \mid H_0), a statement about “no effect.” The bootstrap estimates how far the estimate \hat\theta typically lands from the true \theta, a statement about size and precision.
(2) Null Vs Sampling Distribution: The permutation histogram is centered at the null value of zero, while the bootstrap histogram is centered at the observed estimate. Their widths are often similar, but the centers differ, so neither histogram can be read as the other.
(3) Exchangeability Is The Assumption: Under the null every relabeling of the observed outcomes was equally likely, which random assignment guarantees by design. Strictly, the test is exact for the sharp null F_A = F_B, not merely for equal means.
(4) Exact Vs Asymptotic: A permutation p-value is exact at any n, either over all \binom{n}{n_B} relabelings or over B random shuffles with a +1 correction. Bootstrap intervals carry coverage error that shrinks only as n grows and can undercover with fewer than about 20 units per arm.
(5) Design-Based Vs Sampling-Based: Randomization inference treats the 60 users as fixed and the coin flips as the only randomness, so it speaks about these units. The bootstrap treats users as draws from a population, so its interval describes the population effect.
(6) Resample The Unit Of Randomization: Permute and bootstrap whatever was actually randomized: users rather than sessions, whole clusters rather than members, and sign flips within pairs when two models are scored on the same test examples.

Mathematical Formulation:
T = \bar y_B - \bar y_A
T^{(b)} = T(\pi_b(\mathbf{g}), \mathbf{y})
p = \frac{1 + \sum_{b=1}^{B} \mathbf{1}\{|T^{(b)}| \geq |t_{\mathrm{obs}}|\}}{B + 1}
T^{*(b)} = \bar y_B^{*(b)} - \bar y_A^{*(b)}
\widehat{\mathrm{SE}} = \mathrm{sd}(T^{*(1)}, \ldots, T^{*(B)})
\mathrm{CI}_{0.95} = [q^{*}_{0.025},\ q^{*}_{0.975}]

Where:

  • T is the test statistic, here the difference between the arm means \bar y_B and \bar y_A, and t_{\mathrm{obs}} is its value under the labels that were actually assigned.
  • \mathbf{y} is the vector of all observed outcomes, \mathbf{g} the vector of group labels, and \pi_b a uniformly random permutation of the labels for shuffle b \in \{1, \ldots, B\}; the outcomes never move.
  • \mathbf{1}\{\cdot\} is the indicator function. The +1 in numerator and denominator counts the observed labeling as one of the permutations, which keeps the Monte Carlo p-value valid and never exactly zero.
  • \bar y_A^{*(b)} and \bar y_B^{*(b)} are means of bootstrap resamples that draw n_A units from arm A and n_B units from arm B with replacement; the labels never move.
  • \widehat{\mathrm{SE}} is the standard deviation of the B bootstrap replicates, and q^{*}_{0.025}, q^{*}_{0.975} are their 2.5th and 97.5th percentiles, which form the percentile interval.

The two procedures differ in a single line, and that line is the whole story. The permutation step recomputes T under relabelings that are equally likely only if H_0 holds, so its histogram is the distribution of T conditional on the null, centered near zero. The bootstrap never imposes H_0. It treats each arm’s empirical distribution as the population, so T^{*} scatters around t_{\mathrm{obs}} the way \hat\theta scatters around \theta. The pilot has \binom{60}{30} \approx 1.2 \times 10^{17} relabelings, so B = 10{,}000 random shuffles stand in for them, with a Monte Carlo error of \sqrt{0.033 \times 0.967 / 10^4} \approx 0.0018 on a p-value near 0.033.

Two-panel histogram figure sharing one x-axis of difference in mean watch time. Panel a, permutation: a bell-shaped histogram of 10,000 label shuffles centered at 0, with dashed lines at plus and minus 3.2 minutes and the bars beyond them shaded red, annotated with a two-sided p-value of 0.033. Panel b, bootstrap: a bell-shaped histogram of 10,000 within-arm resamples centered at plus 3.2 minutes, with dashed lines at 0.3 and 6.1 marking the 95 percent percentile interval and a note that zero lift lies just outside it

Figure 1: Same 60 users, same statistic, two distributions. (a) Shuffling the labels 10,000 times builds the null distribution, centered at 0, and the observed 3.2-minute gap sits in its tails with p \approx 0.033. (b) Resampling each arm with replacement builds the sampling distribution, centered at 3.2 minutes, whose 2.5th and 97.5th percentiles give the 95% interval of 0.3 to 6.1 minutes. Both histograms follow the normal approximation with a standard error of 1.5 minutes.

Worked Example:
The old model A produces outcomes 2, 4, 6 and the new model B produces 5, 7, 9, so t_{\mathrm{obs}} = 7 - 4 = 3. Under the null all \binom{6}{3} = 20 ways of choosing which three values carry label B are equally likely, and a split whose B values sum to S has gap (2S - 33)/3. Only \{5, 7, 9\} (gap 3.0) and \{6, 7, 9\} (gap 3.67) reach 3 or more, and their mirror images \{2, 4, 6\} and \{2, 4, 5\} reach -3 or below, so the exact two-sided p-value is 4/20 = 0.20. The bootstrap on the same six numbers gives \widehat{\mathrm{SE}} = \sqrt{8/9 + 8/9} \approx 1.33, so a normal interval 3 \pm 2.6, about 0.4 to 5.6, appears to exclude zero. The disagreement is the lesson. With three points per arm the plug-in variance divides by n instead of n - 1 and shrinks the spread by \sqrt{2/3}, while the permutation p-value is exact.

Side by side, the two methods differ on every axis that matters when choosing between them. The deciding row is usually the first. A launch gate that asks “is it real?” wants the permutation p-value, and a cost-benefit model that needs a number wants the bootstrap interval.

PropertyPermutation testBootstrap
Question answeredIs there any effect at all?How large is the effect, and how precisely is it known?
What gets resampledGroup labels, shuffled without replacement; outcomes stay fixedUnits within each arm, drawn with replacement; labels stay fixed
Distribution builtNull distribution of the statistic, centered at 0Sampling distribution of the estimate, centered at the observed gap
Source of randomnessThe random assignment (design-based)Random sampling of units from a population
Key assumptionLabels exchangeable under the null, guaranteed by randomizationEmpirical distribution is a good stand-in for the population
Small samplesExact at any n; p-values are discrete with a floor of 1 over the number of relabelingsApproximate; intervals undercover when n is small or the statistic is skewed
Main outputA p-valueA standard error and a confidence interval
Fails whenUnits are dependent, clustered, or not randomizedTiny n, extreme statistics such as the maximum, or dependent data

Login to view more content
Log in to track your progress

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *