Skip to content
Tech Interview Prep
Technical interview guide

Hypothesis Testing

The framework for deciding whether an observed effect is likely real or could plausibly be noise: null hypotheses, p-values, and the two ways a test can be wrong.

Minutes to read
3
Practice MCQs
25
Interview Q&A
25
Edition
v7
Editorial status
Reviewed

Scope: Standards and library references current as of 2026-09: NIST/SEMATECH e-Handbook, the 2016 ASA statement on p-values, SciPy, and statsmodels.

Overview

Curated: · Written: · Reviewed:

Hypothesis Testing

In one line

Hypothesis testing checks whether the data is compatible with a stated null of no effect. Reach for it before shipping a change or claiming two options differ. The output is evidence against the null under a stated model, not the probability that the change works.

Key definitions

  • p-value: probability of data at least this extreme if the null is true. It is not P(null | data).
  • Type I error: rejecting a true null. Its rate is bounded by alpha.
  • Type II error: failing to reject a false null. Its rate is 1 minus power.
  • Power: probability of detecting a stated effect at alpha, fixed before the test runs.
  • MDE: the smallest effect the design detects reliably at the chosen alpha and power.
  • TOST: two one-sided tests against a margin set in advance. It is the only valid route to 'no meaningful difference'.

Formulas and complexity

Power=1−β,FWERm=1−(1−α)m\text{Power} = 1 - \beta, \qquad \text{FWER}_m = 1 - (1-\alpha)^m

Twenty independent tests at alpha 0.05:

1−0.9520≈0.641 - 0.95^{20} \approx 0.64

Bonferroni rejects p_i when p_i ≤ alpha/m. Benjamini-Hochberg rejects up to the largest k with p_(k) ≤ (k/m)q.

How it works

Fix alpha, power, MDE and n before data arrives. Compute the statistic under the null and compare p with alpha. Then read the confidence interval against the practical threshold, not against zero alone. Randomise at the unit you analyse, or cluster the errors.

no yes no yes Fix alpha, power, MDE, n Run test at randomisation unit p below alpha? Check CI vs MDE: inconclusive or no meaningful effect CI clears practical threshold? Significant but too small: do not ship Ship, reporting the CI

When to use and when not to

SituationUseAvoid
Two independent means, unequal varianceWelch t-testPooled Student t-test
Two proportions, large nTwo-proportion z-testZ-test on tiny counts
Small counts, pilotFisher exact testZ-test or chi-squared with small expected counts
Skewed data, small nBootstrap for the mean, or Mann-Whitney stated as orderingt-test on heavy skew
Claim of no meaningful differenceTOST against a pre-set marginNon-significant difference test
Many exploratory metricsBenjamini-HochbergBonferroni over hundreds of metrics
Few confirmatory metricsBonferroni or fixed horizonPer-metric peeking
Continuous monitoringGroup sequential boundaries or always-valid inferenceRepeated fixed-sample tests

Traps interviewers probe

  1. Reading p = 0.03 as a 3% chance the null is true. Fix: say it is the chance of data this extreme if there were no difference, then report the effect and its interval.
  2. 'Not significant, so the two are equivalent.' Fix: run TOST with a margin set beforehand, and require the 90% CI to sit inside it.
  3. Post-hoc power computed from the observed effect. Fix: compute the MDE or power for the smallest effect worth acting on, before launch.
  4. Analysing page views when randomising users. Fix: aggregate to the user or use clustered errors, since raw rows make intervals too narrow.
  5. Stopping at the first significant peek, or switching to one-sided after seeing the sign. Fix: fix n or use group sequential boundaries, and fix sidedness in the plan.

Interview tips

Open with: 'The p-value is the chance of data this extreme if there were no difference. I lead with the effect and its interval against the threshold we set before the test.'

Follow-ups to expect:

  • Post-hoc power: it is a function of the p-value you already have, so it adds no information.
  • Choosing alpha: set it from the cost of each error, written down before launch. A false positive that ships a regression and a false negative that leaves a real win unshipped have different costs, so 0.05 should not be the default by habit.
  • Sample ratio mismatch: 12,340 and 11,660 users against 12,000 expected per arm gives a chi-squared statistic of 9.63 + 9.63 = 19.3 on one degree of freedom, p ≈ 1 × 10^-5. Treat the result as invalid until the assignment logic is checked.
  • Welch versus pooled: default to Welch, and never choose between them after looking at the variances.

30-second outline: the claim, the design (alpha, power, MDE, n), the effect with its CI, the decision against the practical threshold, the checks (sample ratio, deviations from plan), then what remains open.

Feedback on this overview

Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.