M1-076M1: Mathematics & Statistics FundamentalsHypothesis TestingEasy
⚡Flashcard Drill➔Mastery:

Explain the Decision Criteria Between Two-Sample t-Test and z-Test

📐 Mathematical Definition
t=Xˉ−μs/n∼tn−1,z=Xˉ−μσ/n∼N(0,1)t=\frac{\bar X-\mu}{s/\sqrt n}\sim t_{n-1},\qquad z=\frac{\bar X-\mu}{\sigma/\sqrt n}\sim\mathcal N(0,1)
⚡ One-Sentence Core Answer
Use a z-test when population variance σ2\sigma^2 is known or sample size NN is very large (N>30N > 30) by CLT; use a t-test when variance is unknown and estimated via sample variance s2s^2 in small-to-moderate samples.

📌 Key Takeaways

  • •
    z-test: Assumes known variance or invokes CLT for large samples; statistic Z=Xˉ−μ0σ/n∼N(0,1)Z = \frac{\bar{X} - \mu_0}{\sigma / \sqrt{n}} \sim \mathcal{N}(0, 1).
  • •
    t-test: Accounts for additional variance from estimating s2s^2; statistic T=Xˉ−μ0s/n∼tn−1T = \frac{\bar{X} - \mu_0}{s / \sqrt{n}} \sim t_{n-1}.
  • •
    Heavier tails: Student's t-distribution has fatter tails than Gaussian, producing more conservative critical values for small NN.

📐 Mathematical Derivations

Derivation of Student's t-distribution: Let X1,…,Xn∼N(μ,σ2)X_1, \dots, X_n \sim \mathcal{N}(\mu, \sigma^2). Then Xˉ∼N(μ,σ2/n)\bar{X} \sim \mathcal{N}(\mu, \sigma^2/n), and (n−1)s2/σ2∼χn−12(n-1)s^2/\sigma^2 \sim \chi^2_{n-1}, with Xˉ\bar{X} and s2s^2 statistically independent by Cochran's theorem. A Student's t-variable is defined as the ratio of a standard normal to the square root of an independent normalized chi-square variable: T=(Xˉ−μ)/(σ/n)((n−1)s2/σ2)/(n−1)=Xˉ−μs/n∼tn−1T = \frac{(\bar{X} - \mu)/(\sigma/\sqrt{n})}{\sqrt{((n-1)s^2/\sigma^2)/(n-1)}} = \frac{\bar{X} - \mu}{s/\sqrt{n}} \sim t_{n-1}. As degrees of freedom ν=n−1→∞\nu = n-1 \to \infty, tν→dN(0,1)t_\nu \xrightarrow{d} \mathcal{N}(0, 1) by Slutsky's theorem.

🏭 Production Trade-offs

In industrial A/B testing where sample size NN is in the millions per variant, the tt-distribution and normal distribution are numerically indistinguishable (t1000000≈N(0,1)t_{1000000} \approx \mathcal{N}(0, 1)). However, Welch's t-test (which relaxes the equal variance assumption: se=sA2/NA+sB2/NB\text{se} = \sqrt{s_A^2/N_A + s_B^2/N_B} with Satterthwaite degrees of freedom) is the industry standard default because equal group variance is rarely guaranteed.
⚠️ Common Interview Pitfalls
  • ✕
    Using Student's t-test with pooled variance when group variances are unequal (violates homoscedasticity; Welch's t-test must be used).
  • ✕
    Assuming t-tests are fully robust to extreme outliers in small sample sizes (N<20N < 20).
🎯 Interviewer Follow-up Inquiries
  • ?
    How does Welch's t-test approximate degrees of freedom via the Welch-Satterthwaite equation?
  • ?
    Why is Welch's t-test preferred over Student's pooled t-test even when sample sizes are equal?
⚡
Test muscle memory on this topic via 3-Layer Flashcards
Active Recall: Mentally formulate Prompt ➔ Math Derivation ➔ Benchmark Implementation in 3 minutes.
🎯 Drill This Card Now➔
📚

Associated Knowledge Base Guides & Mindmaps

Explore the comprehensive technical article, exam cards, and global architecture tree.

← PreviousM1-075: Explain Shrinkage Estimators and the James-Stein Phenomenon📋Back to BankNext →M1-077: Explain the Three Primary Statistical Applications of the Chi-Square Test
中文速览与面试要点

解释 t 检验与 z 检验的选择依据。

z 检验用已知总体方差(或大样本近似);t 检验用样本方差(小样本、方差未知)。

核心要点

  • 选择的判据是' 方差是否已知 '而非单纯的样本量:① z 检验 ——总体标准差 σ 已知(罕见),或样本量很大(n>30–50)时用 CLT 近似;② t 检验 ——σ 未知且用样本标准差 s 替代时,必须用 t 分布。 为什么必须用 t :用 s 替代 σ 引入了 额外的不确定性 (s 本身是随机变量),若仍用正态分布会 低估尾部概率 (导致假阳性膨胀);t 分布正是为补偿这一不确定性而设计的——它的尾部比正态更厚,自由度 ν=n−1 越小尾部越厚,n→∞ 时收敛到正态。 配对 vs 非配对 :配对 t 检验用于同一批对象的两次测量(或用相同配对条件),检验 差值 的均值是否为零,能消除个体差异、大幅降低方差;非配对(独立样本)t 检验用于两组独立样本,需假设方差齐性(否则用 Welch 校正)。
  • 实践要点:① Welch t 检验 ——不假设两组方差相等(默认推荐),自由度用 Welch-Satterthwaite 近似;经典的学生 t 检验假设方差齐性,实践中该假设常不成立(尤其两组样本量差异大时),故 Welch 更稳健。② 样本量的经验阈值 ——'n>30 用 z' 是常见经验,但若数据重偏或重尾,30 远不够;更稳妥的做法是 统一用 t 检验 (大样本下 t 与 z 几乎相同,无损失)。③ 配对设计的前提 ——配对要求两组观测 一一对应 (同一对象的前后测、同一批次的处理/对照);错用配对会低估方差导致假阳性。④ A/B 测试中的应用 ——两组用户独立,用非配对(Welch)t 检验;但若指标重尾,t 检验的 CLT 近似在中等样本下不可靠,应改用 bootstrap 或 Mann-Whitney U(秩和)检验 。⑤ 多重比较 ——同时做多个 t 检验需 Bonferroni/BH 校正。⑥ 与 ANOVA 的关系 ——比较 3 组以上时不应做多次 t 检验(膨胀假阳性),应用 ANOVA + 事后检验。
  • t 分布比正态更重尾(反映方差估计的不确定性)
  • n→∞ 时 t 分布收敛到正态

常见陷阱

  • 用 z 检验而方差未知且样本小(应用 t)
  • 比较三组以上时做多次 t 检验(应用 ANOVA)