# 位置检验

位置检验是一种统计假设检验，用于比较一个或多个分布的位置参数，如均值或中位数。参数版本假定分布形式：t检验针对均值，合并两样本学生t检验假定独立样本和共同方差，而韦尔奇（Welch）两样本t检验不要求总体间方差相等的假设。非参数版本——本主题的核心——针对中位数或伪中位数（从同一分布中独立抽取的u和v的(u+v)/2的中位数；当分布对称时两者重合）。<sup>[1](https://stat.ethz.ch/R-manual/R-devel/library/stats/html/wilcox.test.html)</sup> 命名的位置检验包括符号检验、威尔科克森（Wilcoxon）符号秩检验、曼（Mann）-惠特尼（Whitney）U检验（威尔科克森秩和）、两样本中位数检验，以及k样本克鲁斯卡尔（Kruskal）-沃利斯（Wallis）和弗里德曼（Friedman）检验。<sup>[2](https://reference.wolfram.com/language/ref/LocationTest.en.md)</sup><sup> • </sup><sup>[3](https://pmc.ncbi.nlm.nih.gov/articles/PMC2743502/)</sup> 软件如R的wilcox.test、Wolfram的LocationTest和nptest包将这些作为常规调用提供。<sup>[1](https://stat.ethz.ch/R-manual/R-devel/library/stats/html/wilcox.test.html)</sup><sup> • </sup><sup>[2](https://reference.wolfram.com/language/ref/LocationTest.en.md)</sup><sup> • </sup><sup>[4](https://www.rdocumentation.org/packages/nptest/versions/1.2/topics/np.loc.test)</sup>

| 事实 | 详情 |
|---|---|
| 零假设与备择假设（两样本平移模型） | \( H_{0}: F(x) = G(x) \) 对 \( H_{1}: F(x) = G(x + \Delta) \)<sup>[5](https://journals.plos.org/plosone/article/file?id=10.1371%2Fjournal.pone.0195894&type=printable)</sup> |
| 相对于t检验的效率 | 威尔科克森秩和在正态下的渐近相对效率为0.955；对所有连续分布至少约为0.864<sup>[3](https://pmc.ncbi.nlm.nih.gov/articles/PMC2743502/)</sup><sup> • </sup><sup>[6](https://link.springer.com/article/10.1007/s42952-024-00262-7)</sup> |
| 原始论文 | 威尔科克森（Wilcoxon） (1945)<sup>[7](https://doi.org/10.2307/3001968)</sup>，曼（Mann）与惠特尼（Whitney） (1947)<sup>[8](https://doi.org/10.1214/aoms/1177730491)</sup>，克鲁斯卡尔（Kruskal）与沃利斯（Wallis） (1952)<sup>[9](https://doi.org/10.1080/01621459.1952.10483441)</sup> |
| U度量的是什么 | \( \varphi(F,G) = \Pr[Y_{F} > Y_{G}] + \tfrac{1}{2}\Pr[Y_{F} = Y_{G}] \)<sup>[10](https://pmc.ncbi.nlm.nih.gov/articles/PMC2857732/)</sup> |
| 精确p值 | R中在有限值少于50个时默认；结的处理通过施特赖特贝格（Streitberg）–勒梅尔（Röhmel）平移算法<sup>[1](https://stat.ethz.ch/R-manual/R-devel/library/stats/html/wilcox.test.html)</sup> |
| 主要失效模式 | 仅假定均值相等时在方差不等下无效<sup>[10](https://pmc.ncbi.nlm.nih.gov/articles/PMC2857732/)</sup> |

## 工作原理

非参数位置检验用秩或符号代替数据，因此可以在不假定数据生成分布的情况下计算统计量的零分布。在可交换数据的零假设下，秩向量在\( \{1, \dots, n\} \)的所有\( n! \)个置换上均匀分布，这使得检验无分布。<sup>[11](https://juliastats.org/HypothesisTests.jl/latest/specs/rank_tests/)</sup>

两样本秩和检验通过曼-惠特尼泛函 \( \varphi(F,G) = \Pr[Y_{F} > Y_{G}] + \tfrac{1}{2}\Pr[Y_{F} = Y_{G}] \) 定义；当一个样本倾向于产生更大的值时，拒绝零假设 \( \varphi = 1/2 \)。<sup>[10](https://pmc.ncbi.nlm.nih.gov/articles/PMC2857732/)</sup> 曼和惠特尼证明了该检验对随机排序备择假设 \( F(x) \leq G(x) \)（对每个 \( x \) 成立，且对某些 \( x \) 严格不等）是一致的。<sup>[12](https://projecteuclid.org/journalArticle/Download?urlId=10.1214%2Faoms%2F1177730491&isResultClick=False)</sup> 这比位置平移更广泛：该程序仅在平行累积分布函数的平移模型下检验位置，而将其描述为一般性的“分布差异”检验已被反例证明具有误导性。<sup>[13](https://doi.org/10.1111/bmsp.12162)</sup><sup> • </sup><sup>[14](https://onlinelibrary.wiley.com/doi/10.1002/bimj.4710240102)</sup> 在平移模型下，反演该检验可得到 \( \Delta \) 的置信区间，即霍奇斯（Hodges）-莱曼（Lehmann）估计；两样本估计量估计的是样本间差值的中位数，而不是中位数之差，R文档指出，混淆这两者是一个常见的误解。<sup>[1](https://stat.ethz.ch/R-manual/R-devel/library/stats/html/wilcox.test.html)</sup>

## 具体做法

**符号检验。** 计数高于和低于假设值 \( m_{0} \) 的观测数。在 \( H_{0} \) 下，计数服从参数为 \( n \) 和 \( p = 1/2 \) 的二项分布；当较小的计数太小时，双侧检验拒绝。<sup>[15](https://online.stat.psu.edu/stat415/book/export/html/836)</sup>

**威尔科克森符号秩检验。** 丢弃零差值，对绝对差值排序（结取平均秩），并计算 \( W = \sum_{i=1}^{n} Z_{i} R_{i} \)，其中 \( Z_{i} \) 表示正差值，\( R_{i} \) 是秩；\( W \) 的范围从0到 \( n(n+1)/2 \)。<sup>[15](https://online.stat.psu.edu/stat415/book/export/html/836)</sup><sup> • </sup><sup>[11](https://juliastats.org/HypothesisTests.jl/latest/specs/rank_tests/)</sup> 对于大 \( n \)，\( W' = (W - n(n+1)/4) / \sqrt{n(n+1)(2n+1)/24} \) 近似标准正态。<sup>[15](https://online.stat.psu.edu/stat415/book/export/html/836)</sup> 每组 \( t \) 个结秩使零假设下的方差减少 \( (t^{3} - t)/48 \)。<sup>[16](https://www.jhanley.biostat.mcgill.ca/c607/ch14/jh_ch_14.pdf)</sup>

**曼-惠特尼U / 威尔科克森秩和。** 合并样本，排序，然后要么对一个组的秩求和，要么计数跨组对（结计一半）。\( U \) 的 \( E(U) = 0.5 \cdot n_{1} \cdot n_{2} \) 和 \( \mathrm{Var}(U) = n_{1} \cdot n_{2}(n_{1} + n_{2} + 1)/12 \)，且 \( U_{1} = T_{1} - n_{1}(n_{1}+1)/2 \)，因此两种表述完全等价。<sup>[17](https://people.stat.sc.edu/hansont/stat704/notes3.pdf)</sup><sup> • </sup><sup>[16](https://www.jhanley.biostat.mcgill.ca/c607/ch14/jh_ch_14.pdf)</sup><sup> • </sup><sup>[11](https://juliastats.org/HypothesisTests.jl/latest/specs/rank_tests/)</sup>

**中位数检验。** 计数一个样本中超过所有 \( m + n \) 个观测的全局中位数的值；在 \( H_{0} \) 下该计数服从超几何分布，随机化给出精确显著性水平。<sup>[18](https://eldorado.tu-dortmund.de/server/api/core/bitstreams/bb7cba51-51e7-46c5-902f-89d694300a6d/content)</sup>

精确零分布可以通过两种方式计算：对无结样本的格点递归，成本为 \( O(n^{3}) \)；以及完全置换枚举，成本为 \( O(2^{n}) \)；此外，还有 \( O(n) \) 的正态近似可用，但它不是精确计算。<sup>[11](https://juliastats.org/HypothesisTests.jl/latest/specs/rank_tests/)</sup>

在软件中，R的wilcox.test在样本包含少于50个有限值时默认计算精确p值，否则使用正态近似；存在结时，默认通常不使用精确p值；当请求精确计算时，施特赖特贝格–勒梅尔平移算法为有结和无结样本计算精确条件p值。<sup>[1](https://stat.ethz.ch/R-manual/R-devel/library/stats/html/wilcox.test.html)</sup> Wolfram的LocationTest提供“Sign”、“SignedRank”、“MannWhitney”以及t检验和z检验，默认选择适用的功效最高的检验。<sup>[2](https://reference.wolfram.com/language/ref/LocationTest.en.md)</sup> R包nptest用八种统计量执行随机化检验，包括韦尔奇的t和学生化威尔科克森<sup>[4](https://www.rdocumentation.org/packages/nptest/versions/1.2/topics/np.loc.test)</sup>，而robnptests实现弗里德（Fried）-德林（Dehling）稳健检验，提供置换、随机化或渐近p值。<sup>[19](https://s-abbas.r-universe.dev/robnptests/doc/manual.pdf)</sup>

## 起源

弗兰克·威尔科克森（Frank Wilcoxon）1945年在《生物计量学通报》（*Biometrics Bulletin*）上发表的论文《排序方法进行的个体比较》（*Individual Comparisons by Ranking Methods*）引入了秩和检验，用秩得分 \( 1, 2, 3, \dots, n \) 代替数据，以便在配对和非配对实验中快速获得近似显著性，并给出了5到10次重复的精确表<sup>[7](https://doi.org/10.2307/3001968)</sup><sup> • </sup><sup>[20](https://sci-hub.ru/storage/moscow/1867/6cf7c23f788de9858d4bd1639bb59275/wilcoxon1945.pdf)</sup>；同一篇论文提出了用于配对数据的符号秩方法。<sup>[7](https://doi.org/10.2307/3001968)</sup> H. B. 曼（H. B. Mann）和D. R. 惠特尼（D. R. Whitney）1947年在《数学统计年鉴》（*The Annals of Mathematical Statistics*）上的论文提出了U统计量，通过递推关系计算了直到 \( n = m = 8 \) 的精确概率，并证明了当 \( m, n \) 增大时极限分布为正态分布。<sup>[8](https://doi.org/10.1214/aoms/1177730491)</sup><sup> • </sup><sup>[12](https://projecteuclid.org/journalArticle/Download?urlId=10.1214%2Faoms%2F1177730491&isResultClick=False)</sup> 威廉·H. 克鲁斯卡尔（William H. Kruskal）和W. 艾伦·沃利斯（W. Allen Wallis）于1952年在《美国统计协会杂志》（*Journal of the American Statistical Association*）上将秩方法推广到按秩的单因素方差分析。<sup>[9](https://doi.org/10.1080/01621459.1952.10483441)</sup>

## 变体

单样本形式是符号检验和符号秩检验；配对形式将符号秩检验应用于配对内差值，当差值严重非正态时替代配对t检验。<sup>[21](http://estat.me/estat/eLearning/en/eStatU/chapter10.html)</sup><sup> • </sup><sup>[22](https://stats.libretexts.org/Courses/Las_Positas_College/Math_40%3A_Statistics_and_Probability/12%3A_Nonparametric_Statistics/12.10%3A_Wilcoxon_Signed-Rank_Test)</sup> 两样本形式是秩和（曼-惠特尼）检验和中位数检验。<sup>[18](https://eldorado.tu-dortmund.de/server/api/core/bitstreams/bb7cba51-51e7-46c5-902f-89d694300a6d/content)</sup> 克鲁斯卡尔-沃利斯检验将秩和比较推广到 \( k \) 个独立组，是单因素方差分析的非参数对应方法；弗里德曼检验处理 \( k \) 个相关样本。<sup>[3](https://pmc.ncbi.nlm.nih.gov/articles/PMC2743502/)</sup><sup> • </sup><sup>[21](http://estat.me/estat/eLearning/en/eStatU/chapter10.html)</sup> 基于样本中位数和霍奇斯-莱曼估计的稳健两样本检验由罗兰·弗里德（Roland Fried）和赫罗尔德·德林（Herold Dehling）于2011年提出。<sup>[23](https://doi.org/10.1007/s10260-011-0164-1)</sup> 多变量扩展使用逐分量中位数和霍奇斯-莱曼估计来处理平移假设 \( H_{0}: F(x) = G(x) \) 对 \( H_{1}: F(x) = G(x + \Delta) \)。<sup>[5](https://journals.plos.org/plosone/article/file?id=10.1371%2Fjournal.pone.0195894&type=printable)</sup> 一种最大值型统计量将威尔科克森型位置得分与安萨里（Ansari）-布拉德利（Bradley）尺度统计量配对，用于两阶段设计中的单侧位置-尺度备择假设。<sup>[24](https://link.springer.com/article/10.1007/s10260-024-00775-9)</sup>

## 应用

在正态条件下与t检验相比，威尔科克森秩和检验的渐近相对效率为0.955（等于 \( 3/\pi \)），克鲁斯卡尔-沃利斯检验相对于方差分析的渐近相对效率也是0.955，因此即使参数假设成立，损失的效能也很小。<sup>[3](https://pmc.ncbi.nlm.nih.gov/articles/PMC2743502/)</sup><sup> • </sup><sup>[10](https://pmc.ncbi.nlm.nih.gov/articles/PMC2857732/)</sup> 对于所有连续分布，渐近相对效率至少约为0.864，而正态得分检验相对于t检验的渐近相对效率为1。<sup>[6](https://link.springer.com/article/10.1007/s42952-024-00262-7)</sup> 对于重尾或非常偏斜的分布，WMW方法可能比t检验更有功效，且渐近相对效率可以变为无穷大。<sup>[10](https://pmc.ncbi.nlm.nih.gov/articles/PMC2857732/)</sup><sup> • </sup><sup>[3](https://pmc.ncbi.nlm.nih.gov/articles/PMC2743502/)</sup> 实用建议是：对于近似正态数据使用t检验（此时它更有功效），对于对称但非正态数据使用符号秩检验，对于高度偏斜数据使用符号检验。<sup>[17](https://people.stat.sc.edu/hansont/stat704/notes3.pdf)</sup>

## 局限性与替代方法

如果只假定均值相等，WMW检验是无效的，因为仅方差差异就可能使统计量显著；有效性要求在零假设下 \( F = G \)。<sup>[10](https://pmc.ncbi.nlm.nih.gov/articles/PMC2857732/)</sup> 在结合非正态性和方差异质性的模拟研究中，除曼-惠特尼外所有方法都控制了I类错误率，而曼-惠特尼使其膨胀。<sup>[25](https://li01.tci-thaijo.org/index.php/cast/article/view/249633)</sup> 经典t检验相对稳健：当正态性被违反时它保持渐近有效性<sup>[10](https://pmc.ncbi.nlm.nih.gov/articles/PMC2857732/)</sup>，并且当存在共同方差时两样本t检验是渐近有效的。<sup>[18](https://eldorado.tu-dortmund.de/server/api/core/bitstreams/bb7cba51-51e7-46c5-902f-89d694300a6d/content)</sup> 结和零值需要小心处理：零值在排序前被丢弃，结迫使使用平均秩和基于置换的推断，而添加小的随机噪声（抖动）可以在离散数据上保持显著性水平。<sup>[11](https://juliastats.org/HypothesisTests.jl/latest/specs/rank_tests/)</sup><sup> • </sup><sup>[19](https://s-abbas.r-universe.dev/robnptests/doc/manual.pdf)</sup> 替代方法包括置换和自助法程序（它们从合并样本中近似统计量的分布）<sup>[5](https://journals.plos.org/plosone/article/file?id=10.1371%2Fjournal.pone.0195894&type=printable)</sup>、用于不等方差的学生化威尔科克森检验<sup>[4](https://www.rdocumentation.org/packages/nptest/versions/1.2/topics/np.loc.test)</sup>，以及基于中位数的稳健检验。<sup>[23](https://doi.org/10.1007/s10260-011-0164-1)</sup> 由于WMW方法仅在平移模型下检验位置，效应量最好报告为优势概率，而不是单一的中位数平移。<sup>[13](https://doi.org/10.1111/bmsp.12162)</sup>

## References

1. [R: Wilcoxon Rank Sum and Signed Rank Tests (wilcox.test)](https://stat.ethz.ch/R-manual/R-devel/library/stats/html/wilcox.test.html)
2. [LocationTest, Wolfram Language Reference](https://reference.wolfram.com/language/ref/LocationTest.en.md)
3. [Nonparametric versus parametric tests of location in biomedical research](https://pmc.ncbi.nlm.nih.gov/articles/PMC2743502/)
4. [np.loc.test function - RDocumentation (nptest package)](https://www.rdocumentation.org/packages/nptest/versions/1.2/topics/np.loc.test)
5. [Robust multivariate nonparametric tests for detection of two-sample location shift in clinical trials (PLoS ONE, 2018)](https://journals.plos.org/plosone/article/file?id=10.1371%2Fjournal.pone.0195894&type=printable)
6. [Nonparametric tests for combined location-scale and Lehmann alternatives using adaptive approach and max-type metric (Journal of the Korean Statistical Society, 2024)](https://link.springer.com/article/10.1007/s42952-024-00262-7)
7. [Frank Wilcoxon (1945). Individual Comparisons by Ranking Methods. Biometrics Bulletin.](https://doi.org/10.2307/3001968)
8. [H. B. Mann, D. R. Whitney (1947). On a Test of Whether one of Two Random Variables is Stochastically Larger than the Other. The Annals of Mathematical Statistics.](https://doi.org/10.1214/aoms/1177730491)
9. [William H. Kruskal, W. Allen Wallis (1952). Use of Ranks in One-Criterion Variance Analysis. Journal of the American Statistical Association.](https://doi.org/10.1080/01621459.1952.10483441)
10. [Fay & Proschan (2010), 'Wilcoxon-Mann-Whitney or t-test? On assumptions for hypothesis tests and multiple interpretations of decision rules', Statistics in Medicine](https://pmc.ncbi.nlm.nih.gov/articles/PMC2857732/)
11. [Rank-based location inference · HypothesisTests.jl](https://juliastats.org/HypothesisTests.jl/latest/specs/rank_tests/)
12. [Mann, H. B. & Whitney, D. R. (1947) 'On a Test of Whether one of Two Random Variables is Stochastically Larger than the Other', Annals of Mathematical Statistics 18(1):50–60](https://projecteuclid.org/journalArticle/Download?urlId=10.1214%2Faoms%2F1177730491&isResultClick=False)
13. [When is the Wilcoxon–Mann–Whitney procedure a test of location? Implications for effect-size measures](https://doi.org/10.1111/bmsp.12162)
14. [Hilgers (1982), 'On the Wilcoxon-Mann-Whitney Test as Nonparametric Analogue and Extension of t-Test', Biometrical Journal 24(1):1–15](https://onlinelibrary.wiley.com/doi/10.1002/bimj.4710240102)
15. [Lesson 20: The Wilcoxon Tests (Penn State STAT 415)](https://online.stat.psu.edu/stat415/book/export/html/836)
16. ["Distribution-Free" or "Non-parametric" Methods (McGill C607 course notes)](https://www.jhanley.biostat.mcgill.ca/c607/ch14/jh_ch_14.pdf)
17. [Nonparametric tests (Timothy Hanson, Stat 704, University of South Carolina)](https://people.stat.sc.edu/hansont/stat704/notes3.pdf)
18. [Robust nonparametric tests for the two-sample location problem (Fried & Dehling)](https://eldorado.tu-dortmund.de/server/api/core/bitstreams/bb7cba51-51e7-46c5-902f-89d694300a6d/content)
19. [robnptests: Robust Nonparametric Two-Sample Tests for Location/Scale (R package manual)](https://s-abbas.r-universe.dev/robnptests/doc/manual.pdf)
20. [Wilcoxon, F. (1945) 'Individual Comparisons by Ranking Methods', Biometrics Bulletin 1(6):80–83](https://sci-hub.ru/storage/moscow/1867/6cf7c23f788de9858d4bd1639bb59275/wilcoxon1945.pdf)
21. [Chapter 10 Nonparametric tests (eStat)](http://estat.me/estat/eLearning/en/eStatU/chapter10.html)
22. [12.10: Wilcoxon Signed-Rank Test (McDonald, Statistics LibreTexts)](https://stats.libretexts.org/Courses/Las_Positas_College/Math_40%3A_Statistics_and_Probability/12%3A_Nonparametric_Statistics/12.10%3A_Wilcoxon_Signed-Rank_Test)
23. [Roland Fried, Herold Dehling (2011). Robust nonparametric tests for the two-sample location problem. Statistical Methods & Applications.](https://doi.org/10.1007/s10260-011-0164-1)
24. [A maximum statistic for the one-sided location-scale alternative in the two-stage design (Statistical Methods & Applications, 2024)](https://link.springer.com/article/10.1007/s10260-024-00775-9)
25. [Two-sample Location Tests under Violation of the Normality and Variance Homogeneity Assumptions](https://li01.tci-thaijo.org/index.php/cast/article/view/249633)

---
*Initially written Sep 29, 2026 · Edited: Oct 15, 2026; Oct 25, 2026*

Topic: 物质世界与数学 › 数学与统计学 › 统计学与概率论 › Statistical inference, estimation, sampling, and testing › Hypothesis testing

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/location-test

English original: https://www.edgepedia.org/location-test
