M4-008Medium假设检验 · Hypothesis testing
非参数检验什么时候必须用?有什么代价?
When must you use a non-parametric test, and what does it cost?
💡 考场高分一句话答案:
非参数检验(如 Mann-Whitney U / Wilcoxon 秩和)通过将数据转换为秩次(Rank)消除极端异常值与长尾偏态影响,代价是在正态假设成立时损失约 5% 的统计功效。
With severe skew, small samples, or ordinal outcomes. The cost is usually lower power, and it tests distributions or medians rather than means.
📌 核心考察要点 (Key Points)
- 常用:Mann-Whitney U(两组)、Wilcoxon 符号秩(配对)、Kruskal-Wallis(多组)
- 适用:重尾、含极端值、序数评分(1–5 星)
- 代价:检验的是“随机抽一个样本大于另一个的概率”,不是均值差;功效低约 5–15%
- 替代:大样本下 bootstrap 更灵活,能直接给均值差的 CI
- Common choices: Mann-Whitney U (two groups), Wilcoxon signed-rank (paired), Kruskal-Wallis (multiple groups)
- Suits: heavy tails, extreme values, ordinal ratings
- Cost: it tests the probability that a random draw from one group exceeds the other, not the mean difference; power is typically 5–15% lower
- Alternative: at large n bootstrap is more flexible and gives a CI for the mean difference
📐 第一性原理与数理推导机理
Mann-Whitney U 检验将两组样本混合排序赋予秩次。检验统计量为:$$U_1 = R_1 - \frac{n_1(n_1 + 1)}{2}$$其中 $R_1$ 为组 1 的秩总和。在大样本下,$U_1$ 渐近正态:均值 $\mathbb{E}[U] = \frac{n_1 n_2}{2}$,方差 $\mathrm{Var}(U) = \frac{n_1 n_2(n_1 + n_2 + 1)}{12}$。因此其统计量 $Z = \frac{U_1 - \mathbb{E}[U]}{\sqrt{\mathrm{Var}(U)}} \sim \mathcal{N}(0, 1)$。
⚠️ 常见高频面试陷阱与避坑指南
- 误以为非参数检验检验的是中位数相等(其实检验的是随机占优性 $P(X > Y) = 0.5$,仅在两组分布形状完全相同时才等价于中位数检验)。
- 在样本量数万级且满足中心极限定理时,盲目使用非参数检验,白白损耗检验功效(ARE 约为 95%)。
🔍 大厂面试官连环追问 (Follow-ups)
- 在长尾分布(如用户在搜索页的停留时长)中,什么时候必须用非参数检验?什么时候用对数转换做 t 检验更好?
- 如果两组分布形状完全不同(一组双峰,一组单峰),Mann-Whitney U 检验的结果该如何解释?
嫌字多看太累?进入苏格拉底式对话推演实验室
零打字负担,以大厂考官真实困境切入,通过点选直觉选项暴露思维盲区,手把手推导 Why。
⚡
想检验本题的肌肉记忆?进入 3 阶闪卡主动回忆盲测
隐藏答案遮罩,自测:审题锚点 ➔ 数理公式机理 ➔ 工业标杆代码与连环追问。3 分钟攻破认知盲区!