This is an IntvML Pro interview question. Upgrade to Pro to unlock the full prompt, diagrams, and solution.
Tag: Data Eng
ML0165 Streaming Sketches: Count-Min & HLL
This is an IntvML Pro interview question. Upgrade to Pro to unlock the full prompt, diagrams, and solution.
ML0163 Feature Hashing & Collision Cost
This is an IntvML Pro interview question. Upgrade to Pro to unlock the full prompt, diagrams, and solution.
ML0156 Stratified Sampling & Quota Design
This is an IntvML Pro interview question. Upgrade to Pro to unlock the full prompt, diagrams, and solution.
ML0153 VC Dimension & Sauer-Shelah
This is an IntvML Pro interview question. Upgrade to Pro to unlock the full prompt, diagrams, and solution.
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.

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
, a statement about “no effect.” The bootstrap estimates how far the estimate
typically lands from the true
, 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, not merely for equal means.
(4) Exact Vs Asymptotic: A permutation p-value is exact at any n, either over allrelabelings or over
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:
Where:
is the test statistic, here the difference between the arm means
and
, and
is its value under the labels that were actually assigned.
is the vector of all observed outcomes,
the vector of group labels, and
a uniformly random permutation of the labels for shuffle
; the outcomes never move.
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.
and
are means of bootstrap resamples that draw
units from arm A and
units from arm B with replacement; the labels never move.
is the standard deviation of the
bootstrap replicates, and
,
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
under relabelings that are equally likely only if
holds, so its histogram is the distribution of
conditional on the null, centered near zero. The bootstrap never imposes
. It treats each arm’s empirical distribution as the population, so
scatters around
the way
scatters around
. The pilot has
relabelings, so
random shuffles stand in for them, with a Monte Carlo error of
on a p-value near 0.033.

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
. (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. Under the null all
ways of choosing which three values carry label B are equally likely, and a split whose B values sum to
has gap
. Only
(gap 3.0) and
(gap 3.67) reach 3 or more, and their mirror images
and
reach -3 or below, so the exact two-sided p-value is
. The bootstrap on the same six numbers gives
, so a normal interval
, 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
instead of
and shrinks the spread by
, 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.
Property Permutation test Bootstrap Question answered Is there any effect at all? How large is the effect, and how precisely is it known? What gets resampled Group labels, shuffled without replacement; outcomes stay fixed Units within each arm, drawn with replacement; labels stay fixed Distribution built Null distribution of the statistic, centered at 0 Sampling distribution of the estimate, centered at the observed gap Source of randomness The random assignment (design-based) Random sampling of units from a population Key assumption Labels exchangeable under the null, guaranteed by randomization Empirical distribution is a good stand-in for the population Small samples Exact at any n; p-values are discrete with a floor of 1 over the number of relabelings Approximate; intervals undercover when n is small or the statistic is skewed Main output A p-value A standard error and a confidence interval Fails when Units are dependent, clustered, or not randomized Tiny n, extreme statistics such as the maximum, or dependent data Login to view more contentML0145 Spurious Regression & Non-Stationarity
This is an IntvML Pro interview question. Upgrade to Pro to unlock the full prompt, diagrams, and solution.

