EasyDeepLearn
Statistics Fundamentals · section 6 of 15

Hypothesis testing

33 interview questions on hypothesis testing, each answered in full. Free to read, no account needed.

What is a p-value, precisely?

easy
  • The probability, assuming the null hypothesis is true, of observing a test statistic at least as extreme as the one obtained.
  • It is NOT the probability that the null is true, nor the probability of a mistake.
  • A small p-value means the data are unlikely under H0.
  • Combine with effect size and confidence intervals — never rely on p-values alone.
#hypothesis-testingPermalink & quiz →

Type I vs Type II error — what's the difference?

easy
  • Type I error (false positive): rejecting H0 when it's actually true.
  • Its probability is alpha (significance level, often 0.05).
  • Type II error (false negative): failing to reject H0 when H1 is true.
  • Its probability is beta; power  =  1    β\mathrm{power}\; = \;1\; - \;\beta.
  • There's a tradeoff — lowering alpha raises beta unless you increase sample size or effect size.
#hypothesis-testing#powerPermalink & quiz →

Why is multiple testing a problem and how do you correct for it?

medium
  • Running many independent tests at α  =  0.05\alpha\; = \;0.05 will produce many false positives by chance alone (5% per test).
  • Corrections: Bonferroni (divide alpha by number of tests — very conservative), Holm-Bonferroni (stepwise, better power), or control the False Discovery Rate with Benjamini-Hochberg (best for discovery-style work with many tests).
#hypothesis-testing#multiple-testingPermalink & quiz →

How do you formulate null and alternative hypotheses?

easy
  • Null H0: the 'no effect' / 'no difference' hypothesis (μA  =  μB,  β  =  0,  treatment  has  no  impact)({\mu}_{A}\; = \;{\mu}_{B}, \;{\beta}\; = \;0, \;\mathrm{treatment}\;\mathrm{has}\;\mathrm{no}\;\mathrm{impact}).
  • Alternative H1: what we suspect (μA    μB  twosided,  or  μA  >  μB  onesided)({\mu}_{A}\; \ne \;{\mu}_{B}\;\mathrm{two} - \mathrm{sided}, \;\mathrm{or}\;{\mu}_{A}\; > \;{\mu}_{B}\;\mathrm{one} - \mathrm{sided}).
  • One-sided tests are more powerful but only appropriate when you commit ex ante to the direction.
  • Rule: define H0 / H1 before seeing the data.
  • Post-hoc directional testing inflates type I error.
#hypothesis-testingPermalink & quiz →

One-sample t-test: setup and assumptions.

easy
  • H0: μ  =  μ0{\mu}\; = \;{\mu}_{0}.
  • Statistic: t  =  (X    μ0)  /  (s  /  n)t\; = \;(X\; - \;{\mu}_{0})\; / \;(s\; / \; \sqrt n), where s is sample SD.
  • Under H0 and normality, t ~ tn1t_{n - 1}.
  • Assumptions: (1) i.i.d. samples; (2) approximately normal (robust for n > 30 due to CLT).
  • Compare t to t-distribution quantiles or compute a p-value.
  • Use case: is the mean of a metric different from a target?
#hypothesis-testing#parametric-testsPermalink & quiz →

Two-sample t-test: pooled vs Welch — when to use each?

medium
  • Compare two group means.
  • Pooled (Student's): assumes equal variances → uses pooled SD, df  =  n1  +  n2    2\mathrm{df}\; = \;n_{1}\; + \;n_{2}\; - \;2.
  • Welch's: doesn't assume equal variances → uses Satterthwaite df correction.
  • In practice, Welch is the safer default (behavior similar to Student when variances are equal, better when they aren't).
  • Both assume i.i.d. within groups and approximate normality (CLT-robust for larger n).
#hypothesis-testing#parametric-testsPermalink & quiz →

When do you use a paired t-test?

easy
  • Same subjects measured under two conditions (before / after treatment), or naturally paired observations (twins, matched pairs).
  • Compute differences di  =  XAi    XBid_{i}\; = \;X_{A}i\; - \;X_{B}i, then one-sample t on d.
  • Much more powerful than an unpaired test when the within-pair correlation is high — cancels out subject-level variation.
  • Assumption: differences approximately normal (CLT-robust for n > 30).
#hypothesis-testing#parametric-testsPermalink & quiz →

z-test vs t-test — when to pick each?

easy
  • z-test: known population variance (rare in practice), or very large n (>~100) where t-distribution ≈ normal. t-test: unknown population variance (usual case).
  • For proportions with large n: z-test for a proportion or two-proportion z-test.
  • The 'z-test for a proportion' is common in A/B testing.
  • Modern practice: default to t-test unless you specifically know σ.
#hypothesis-testing#parametric-testsPermalink & quiz →

Chi-square test of independence — what does it do?

medium
  • Tests whether two categorical variables are independent, given an r × c contingency table.
  • Statistic: χ2  =  Σ{\chi}^{2}\; = \;{\Sigma} (Oij    Eij)2  /  Eij(O_{\mathrm{ij}}\; - \;E_{\mathrm{ij}})^{2}\; / \;E_{\mathrm{ij}}, where Eij  =  rowi    colj  /  NE_{\mathrm{ij}}\; = \;\mathrm{row}_{i}\; \cdot \;\mathrm{col}_{j}\; / \;N under independence. df = (r-1)(c-1).
  • Requires EijE_{\mathrm{ij}} ≥ 5 for validity.
  • Use case: is conversion rate independent of region?
  • For small counts, use Fisher's exact test instead.
#hypothesis-testing#parametric-testsPermalink & quiz →

Chi-square goodness-of-fit test — setup.

medium
  • Tests whether observed frequencies match an expected distribution: χ2  =  Σ{\chi}^{2}\; = \;{\Sigma} (Oi    Ei)2  /  Ei(O_{i}\; - \;E_{i})^{2}\; / \;E_{i}, df = k - 1 - (parameters estimated).
  • Uses: is a die fair?
  • Does a dataset follow Poisson?
  • Requires EiE_{i} ≥ 5 (aggregate small buckets).
  • Modern alternatives: G-test (likelihood ratio), Kolmogorov-Smirnov (continuous), Anderson-Darling (heavier weight on tails).
#hypothesis-testing#parametric-testsPermalink & quiz →

What does one-way ANOVA test?

medium
  • H0: μ1  =  μ2{\mu}_{1}\; = \;{\mu}_{2} = ... = μk{\mu}_{k} (all group means equal).
  • Statistic: F = between-group variance / within-group variance ~ Fk1,  NkF_{k - 1, \;N - k} under H0.
  • Assumptions: (1) i.i.d. within groups; (2) normally distributed; (3) equal variances (Welch's ANOVA relaxes this).
  • If F is significant, follow-up with post-hoc tests (Tukey HSD, Bonferroni) to identify which groups differ.
  • Non-parametric alternative: Kruskal-Wallis.
#hypothesis-testing#parametric-testsPermalink & quiz →

Two-way ANOVA and what interactions mean.

hard
  • Tests three effects at once: main effect of factor A, main effect of factor B, and A×B interaction.
  • Interaction: the effect of A depends on the level of B.
  • Significant interaction means main effects are hard to interpret in isolation (plot cell means to visualize).
  • Assumptions: normality + equal variances + independence within cells.
  • Foundation of factorial experimental design.
#hypothesis-testing#parametric-testsPermalink & quiz →

Mann-Whitney U (Wilcoxon rank-sum) — when and why?

medium
  • Non-parametric test comparing two independent groups.
  • Combines all data, ranks it, compares rank sums between groups.
  • Doesn't assume normality — good for skewed, ordinal, or small-sample data.
  • Effectively tests whether one distribution is shifted vs the other.
  • Less powerful than t-test when normality holds; more robust when it doesn't.
  • Not exactly a 'test of medians' — it's a stochastic-dominance test.
#hypothesis-testing#non-parametricPermalink & quiz →

Wilcoxon signed-rank test — setup.

medium
  • Non-parametric alternative to the paired t-test.
  • Compute differences did_{i}, rank  di\operatorname{rank}\; \mid d_{i}|, sum ranks separately for positive and negative differences.
  • Null: distribution of differences is symmetric around zero.
  • Robust to non-normal differences, sensitive to outliers still (unlike sign test).
  • Uses ranks so drops information but keeps power when normality is doubtful.
#hypothesis-testing#non-parametricPermalink & quiz →

Kruskal-Wallis — non-parametric ANOVA analog.

medium
  • Extends Mann-Whitney to k > 2 groups.
  • Rank all data across groups, compute H = 12/(N(N+1)) * Σ (Ri2  /  ni)    3(N+1)(R_{i}^{2}\; / \;n_{i})\; - \;3(N + 1) ~ χ2k1{\chi}^{2}k - 1 approximately.
  • Null: all groups drawn from same distribution.
  • If significant, follow up with pairwise Mann-Whitney with Bonferroni.
  • Use for skewed / ordinal / non-normal data with 3+ groups.
#hypothesis-testing#non-parametricPermalink & quiz →

Friedman test and its use case.

hard
  • Non-parametric alternative to repeated-measures ANOVA.
  • Same subjects rated on k treatments; rank within each subject, sum ranks per treatment.
  • Null: no treatment effect.
  • Useful for within-subject designs where normality is violated.
  • Follow-up: pairwise Wilcoxon with correction.
  • Common in ML benchmarking (rank algorithms across datasets).
#hypothesis-testing#non-parametricPermalink & quiz →

Kolmogorov-Smirnov test — one- and two-sample.

medium
  • Statistic: D  =  maxx  F1(x)    F2(x)D\; = \;\operatorname{max}_{x}\; \mid F_{1}(x)\; - \;F_{2}(x)| — max vertical distance between two ECDFs (two-sample) or between empirical and theoretical CDF (one-sample).
  • Distribution-free, works for continuous data, sensitive to shifts in location, scale, or shape.
  • Weakness: less sensitive in the tails.
  • Use in drift detection (compare distribution today vs baseline).
#hypothesis-testing#non-parametricPermalink & quiz →

Shapiro-Wilk normality test — when useful?

medium
  • Tests whether data comes from a normal distribution.
  • Very sensitive for n < 50; over-powered for large n (reports significant non-normality for trivial deviations).
  • Practical rule: for large samples, rely more on Q-Q plots than on the p-value.
  • Alternatives: Anderson-Darling (weighted toward tails), Kolmogorov-Smirnov (less sensitive), Lilliefors (KS variant with estimated params).
#hypothesis-testingPermalink & quiz →

How do you test equality of variances?

medium
  • Bartlett: assumes normality; sensitive to non-normality.
  • Levene: uses absolute deviations from mean or median (Brown-Forsythe uses median); more robust.
  • F-test of variances: strictly two-sample under normality.
  • Use Levene (with median) as the safe default.
  • Purpose: check equal-variance assumption for ANOVA / pooled t-test; if violated, use Welch's variants.
#hypothesis-testing#parametric-testsPermalink & quiz →

Why report effect size alongside p-values?

easy
  • P-values conflate signal size with sample size — huge n makes trivial effects significant.
  • Effect size quantifies practical importance regardless of n.
  • Common measures: Cohen's d (standardized mean difference: 0.2 small, 0.5 medium, 0.8 large); odds ratio / relative risk (binary outcomes); Pearson r  /  R2r\; / \;R^{2}; Cliff's delta (non-parametric).
  • Always report effect size with CIs and p-values.
#hypothesis-testing#powerPermalink & quiz →

What is power analysis and how do you use it?

medium
  • Power  =  P(reject  H0    H1  true)  =  1    β\mathrm{Power}\; = \;P(\mathrm{reject}\;\mathrm{H0}\; \mid \;\mathrm{H1}\;\mathrm{true})\; = \;1\; - \;{\beta}.
  • Power analysis: given effect size, α, and power (typically 0.8), solve for required sample size.
  • Or: given n, α, effect size, solve for achieved power.
  • Uses: (1) plan A/B tests (how many users do we need?); (2) diagnose 'no significant effect' — was the study under-powered?
  • Free tools: G*Power, statsmodels.power.
  • Always do this before running an experiment.
#hypothesis-testing#powerPermalink & quiz →

What is MDE (minimum detectable effect)?

medium
  • Smallest effect size the experiment can detect with a target power (usually 0.8) given the sample size and α.
  • Computed via power formula.
  • Practical use: 'with N=10000 users per arm at α=0.05 and power 0.8, the MDE is a 2% lift'.
  • If your product intuition says the effect might be 1%, you need to grow n.
  • Cornerstone of A/B testing capacity planning.
#hypothesis-testing#power#ab-testingPermalink & quiz →

Bonferroni correction — how does it work?

medium
  • For k independent tests at family-wise error rate α: use αadjusted  =  α  /  k{\alpha}_{\mathrm{adjusted}}\; = \;{\alpha}\; / \;k per test.
  • Guarantees P(any false rejection) ≤ α under independence, ≤ α always (union bound).
  • Very conservative — loses power quickly as k grows.
  • Use for a small number of confirmatory tests (< 20).
  • Holm's step-down variant is uniformly more powerful with the same guarantee.
#hypothesis-testing#multiple-testingPermalink & quiz →

How does the Benjamini-Hochberg procedure work?

hard
  • Controls the FDR (expected fraction of false positives among rejections) at level q.
  • Steps: (1) Sort p-values p_(1) ≤ ... ≤ p_(m).
  • (2) Find largest k such that p_(k) ≤ (k/m) * q.
  • (3) Reject all H_(i) with i ≤ k.
  • Much more powerful than Bonferroni for large m — accepts a small fraction of false positives to detect many true effects.
  • Standard in genomics, feature selection, high-dim testing.
#hypothesis-testing#multiple-testingPermalink & quiz →

What is a permutation test?

medium
  • Non-parametric test based on the exchangeability principle: shuffle group labels, recompute the test statistic, build a null distribution empirically.
  • Compute p-value = fraction of permutations with statistic ≥ observed.
  • Works for any statistic (mean,  median,  difference  in  R2)(\mathrm{mean}, \;\mathrm{median}, \;\mathrm{difference}\;\mathrm{in}\;R^{2}).
  • Distribution-free, only assumes exchangeability under H0.
  • Slow (usually 10k+ shuffles) but very general.
  • Modern default when you want strong assumption independence.
#hypothesis-testing#non-parametricPermalink & quiz →

What does McNemar's test do?

hard
  • Paired categorical (usually binary) test.
  • Compares proportions in matched pairs.
  • From a 2×2 table of concordant / discordant pairs, χ2  =  (b    c)2  /  (b  +  c){\chi}^{2}\; = \;(b\; - \;c)^{2}\; / \;(b\; + \;c) approximately (or exact binomial for small counts).
  • Uses: classifier comparison on the same test set (does model A get more test items right than model B?), before / after intervention on the same subjects.
#hypothesis-testing#non-parametricPermalink & quiz →

When to use Fisher's exact test?

medium
  • 2×2 (or r×c) contingency table with small expected counts (E < 5) where chi-square approximation fails.
  • Computes an exact p-value from the hypergeometric distribution.
  • Slow for large tables.
  • Standard for small clinical trials, rare-event categorical data.
  • Modern alternative for larger tables: Monte Carlo χ2{\chi}^{2} (simulate null distribution).
#hypothesis-testing#parametric-testsPermalink & quiz →

What is p-hacking and how do you prevent it?

medium
  • Running many analyses (test variants, subgroups, transformations) until you find p < 0.05, then reporting only the significant results.
  • Inflates false-positive rate dramatically.
  • Prevention: (1) pre-register hypotheses + analysis plan; (2) Bonferroni / FDR on all tested variants; (3) separate exploration (open) from confirmation (locked test set + pre-registered stat plan); (4) report all comparisons, not just significant ones.
  • Foundation of the replication crisis.
#hypothesis-testing#multiple-testingPermalink & quiz →

FWER vs FDR — which do you control when?

hard
  • FWER (Family-Wise Error Rate): P(any false rejection).
  • Controlled by Bonferroni / Holm — safe when even a single false positive is costly (safety, regulatory).
  • FDR (False Discovery Rate): E[false / total rejections].
  • Controlled by Benjamini-Hochberg — accepts some false positives to keep power in discovery / exploratory settings.
  • Rule: FWER for confirmatory / high-stakes; FDR for exploratory / genomics / feature selection.
#hypothesis-testing#multiple-testingPermalink & quiz →

How is a CI related to a hypothesis test?

medium
  • A 95% CI for a parameter includes all null values that would NOT be rejected at α = 0.05 in a two-sided test.
  • Equivalently: if 0 is outside the 95% CI of the difference, then reject H0: no difference at α = 0.05.
  • CIs are more informative — they give you the range of plausible values, not just accept / reject.
  • Always report CIs.
#hypothesis-testing#confidence-intervalPermalink & quiz →

Why is peeking at running A/B tests dangerous?

hard
  • Peeking = repeatedly running a test and stopping when p < 0.05 → hugely inflates false-positive rate (up to ~40% for one-sided at α=0.05).
  • Fixes: (1) commit to sample size ex ante and don't peek.
  • (2) Sequential testing: mSPRT, α-spending (Pocock, O'Brien-Fleming), Bayesian sequential decisions.
  • (3) Always-valid inference (Howard & Ramdas): give up 10-20% efficiency for the freedom to check any time.
  • Optimizely / Statsig / Eppo implement always-valid or sequential correctly.
#hypothesis-testing#ab-testingPermalink & quiz →

What is alpha-spending in sequential testing?

hard
  • Divide the total α (0.05) across scheduled interim looks so cumulative false-positive rate stays capped.
  • Pocock: uniform per look (conservative).
  • O'Brien-Fleming: tiny α early, most saved for the final look (encourages waiting).
  • Haybittle-Peto: small α at interims, α - 0.001 at final.
  • All maintain family-wise error at 0.05 across multiple looks — enables ethical stopping in clinical trials.
#hypothesis-testing#ab-testing#multiple-testingPermalink & quiz →

A product manager asks what a p-value of 0.03 means. What do you say?

easy
  • Say that if the change truly had no effect, you would see a difference this large or larger about 3% of the time by chance alone.
  • Then say what it does not mean, because that is where decisions go wrong: it is not the probability that the change works, and it is not the probability that the null hypothesis is true.
  • Add the part that actually matters for the decision, which is the effect size and its confidence interval, since a significant result whose interval spans from trivially small to large does not justify a launch.
  • Frame the conclusion as a decision under uncertainty, weighing the cost of shipping a neutral change against the cost of missing a real one, rather than as a verdict delivered by the threshold.
#hypothesis-testingPermalink & quiz →

Practise Statistics Fundamentals