The interview problem
Two models are evaluated on the same users. Design a permutation test of improvement without destroying the pairing or pretending repeated user events are independent.
Original practice, not a reported company interview. All scenarios and worked numbers are illustrative. Interview date: not applicable. Sources retrieved September 30, 2026.
1. Scope and assumptions
Specify the null that makes within-pair label swaps valid. For observational paired differences, sign flipping requires an appropriate symmetry/exchangeability assumption; a zero mean alone is insufficient.
2. Worked approach
Choose the statistic before inspecting permutations, such as mean per-user improvement. Under the justified paired-swap null, exchange model labels independently within each user and recompute the statistic. Enumerate all swaps for tiny samples or draw random swaps with a reproducible generator.
Keep all events of a user together. If assignment occurred by team, the permutation unit must respect that design. State whether the alternative is one-sided or two-sided and how ties and equally extreme outcomes are counted. A p-value is not the probability that the null is true.
3. Calculate the example
With three paired improvements (1,2,3), the observed sum is 6. There are 2³=8 sign configurations. Only all-positive signs achieve a sum at least 6, so the exact one-sided p-value is 1/8=0.125 under the sign-swap null. For an absolute-sum two-sided convention, both +6 and −6 count, giving 2/8=0.25. Different conventions must be stated rather than mixed.
4. Failure cases and trade-offs
Permuting individual clicks within users creates fake sample size. Choosing a metric after seeing which one is significant invalidates a simple prespecified test interpretation. Reporting zero p-value after finite random permutations ignores Monte Carlo resolution.
Exact enumeration is transparent but grows exponentially. Randomized permutations trade compute for Monte Carlo error; a common conservative estimate includes the observed configuration using (b+1)/(B+1). This adjustment does not repair an invalid exchangeability assumption.
5. Validate the result
Enumerate the eight configurations, verify pairing survives every transformation and compare randomized estimates with the exact result. Report the test unit, null, alternative and number of permutations with the effect estimate.
6. Interview follow-ups and self-review
What changes for clustered randomization? Does no significance demonstrate equivalence?
Reward a defensible null, paired transformations, exact arithmetic and honest p-value interpretation.
Sources and related practice
Technical reference: docs.scipy.org — Official permutation definitions and randomized p-value convention; three-pair example is original.
Exact publication/update date not established in this review. Retrieved September 30, 2026. This reference supports the named technical concept; the proposed workflow and examples are original, not a documented vendor implementation or interview report.
Continue with A/B tests: from randomization to a decision; Choose a bootstrap strategy for dependent observations.
Continue your preparation
Choose a connected learning path or browse more ML fundamentals questions. Read our editorial method and attribution policy.