# 中位数检验

中位数检验是一种非参数统计方法，用于检验两个或多个独立样本是否来自中位数相同的总体。其做法是将每个观测值按高于或低于合并数据的中位数进行分类，再对由此得到的列联表进行分析。<sup>[1](https://methods.sagepub.com/ency/edvol/sage-encyclopedia-of-educational-research-measurement-evaluation/chpt/median-test#_)</sup> 尽管它常被表述为等中位数检验，但这一解释只有在关于总体分布的进一步假设下才成立。<sup>[2](https://st551.cwick.co.nz/lecture/lecture_25/)</sup> 当两样本 t 检验或单因素方差分析所依赖的正态性假设不成立时，实际工作者通常会求助于这一方法；该检验也被广泛称为 Mood 中位数检验。<sup>[3](https://www.jmp.com/en/statistics-knowledge-portal/inferential-statistics/hypothesis-testing/median-test)</sup>

| 关键事实 | 详情 |
|---|---|
| 原假设 | 各独立样本抽自中位数相同的总体（仅在附加假设下才可作为中位数比较）<sup>[1](https://methods.sagepub.com/ency/edvol/sage-encyclopedia-of-educational-research-measurement-evaluation/chpt/median-test#_)</sup><sup> • </sup><sup>[2](https://st551.cwick.co.nz/lecture/lecture_25/)</sup> |
| 机制 | 以全部合并数据的总中位数为界，将每个样本二分为高于和低于两部分；对所得的 2×k 表进行独立性卡方检验<sup>[4](https://www.itl.nist.gov/div898/software/dataplot/refman1/auxillar/meditest.htm)</sup> |
| 检验统计量 | 对 2×2 或 2×k 表计算 Pearson 卡方，自由度为 1 或 \( k - 1 \)<sup>[5](https://www.mdpi.com/2227-7390/14/9/1449)</sup> |
| 小样本 | 观测数约少于 20 或样本严重不平衡时，建议使用费希尔精确检验<sup>[6](https://www.statistics4u.com/fundstat_eng/ee_mediantest.html)</sup> |
| 效能效率 | 小样本下约为两样本 t 检验的 95%；渐近效率趋近 \( 2/\pi \)，约 63%<sup>[7](https://mvpprograms.com/help/mvpstats/nonparametric-tests)</sup> |
| 中位数处的结值 | 软件可将结值计为低于、计为高于或完全忽略；数据集较小时，p 值可能对这一选择敏感<sup>[8](https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.median%5Ftest.html)</sup> |
| 软件 | Python 中的 scipy.stats.median_test；R 中的 mood.medtest（RVAideMemoire）与 median_test（coin）<sup>[8](https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.median%5Ftest.html)</sup><sup> • </sup><sup>[9](https://rcompanion.org/handbook/F_09.html)</sup> |

## 工作原理

该检验将位置比较转化为一个列联表问题。给定 k 个样本，观测数分别为 \( n_{1}, n_{2}, \ldots, n_{k} \)，实际工作者先计算全部 \( n_{1} + n_{2} + \cdots + n_{k} \) 个观测值合并后的总中位数，然后统计每个样本中有多少观测值高于该值、多少等于或低于该值，从而得到一个 2×k 表。中位数检验就是对这张表应用独立性卡方检验的特例。<sup>[4](https://www.itl.nist.gov/div898/software/dataplot/refman1/auxillar/meditest.htm)</sup>

在更强的原假设下——即各样本抽自同一连续分布，因而组标签可交换——样本 1 中高于总中位数的观测数在给定表边际的条件下服从超几何分布，标准化统计量 \( Z = (A_{1} - E[A_{1}]) / \sqrt{\mathrm{Var}(A_{1})} \) 渐近服从正态分布；仅中位数相等并不足以得到这一精确的原假设分布。<sup>[5](https://www.mdpi.com/2227-7390/14/9/1449)</sup> 等价地，在 2×2 情形下，Pearson 统计量 \( \chi^{2} = \sum_{i=1}^{2} \sum_{j=1}^{2} (O_{ij} - E_{ij})^{2} / E_{ij} \) 等于紧凑形式 \( \chi^{2} = N(A_{1}B_{2} - A_{2}B_{1})^{2} / (n_{1} n_{2} A B) \)，自由度为 1。<sup>[5](https://www.mdpi.com/2227-7390/14/9/1449)</sup> 由于在原假设下，各组高于合并中位数的比例期望相等，两样本检验便归结为两个比例的比较，其显著性可由费希尔精确检验得到。<sup>[7](https://mvpprograms.com/help/mvpstats/nonparametric-tests)</sup>

## 操作步骤

流程很短。第一步，合并全部观测值并计算总中位数。第二步，将每个样本中的每个观测值按高于或低于该值分类，构成列联表。第三步，由该表计算卡方统计量与 p 值；例如，SciPy 的 median_test 会构造该表并将其传给 chi2_contingency。<sup>[8](https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.median%5Ftest.html)</sup>

总中位数处的结值需要做出决定。SciPy 的 ties 选项可将其计为“低于”、计为“高于”或完全忽略，其文档警告说，如果数据集不大且含有等于中位数的值，p 值可能对选择敏感。<sup>[8](https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.median%5Ftest.html)</sup> 将结值归入等于/低于单元格或将其均匀拆分，在渐近意义上影响可忽略。<sup>[5](https://www.mdpi.com/2227-7390/14/9/1449)</sup> 在 R 中，该检验可通过 RVAideMemoire 包的 mood.medtest 或 coin 包的 median_test 使用，事后两两比较可通过 rcompanion 的 pairwiseMedianTest 进行；一个三组示例报告卡方值 = 3.36，自由度 = 2，p 值 = 0.1864。<sup>[9](https://rcompanion.org/handbook/F_09.html)</sup>

## 起源

该检验的机制源自经典列联表分析：由费希尔精确概率检验和 Karl Pearson 的卡方检验所评估的 2×2 表。<sup>[1](https://methods.sagepub.com/ency/edvol/sage-encyclopedia-of-educational-research-measurement-evaluation/chpt/median-test#_)</sup><sup> • </sup><sup>[6](https://www.statistics4u.com/fundstat_eng/ee_mediantest.html)</sup> 向两组以上设计（用 Pearson 卡方分析）的推广以及向线性假设的推广，均记载于二十世纪中叶关于中位数检验的文献中。<sup>[1](https://methods.sagepub.com/ency/edvol/sage-encyclopedia-of-educational-research-measurement-evaluation/chpt/median-test#_)</sup>

## 变体

两样本形式给出 2×2 表；k 样本形式使用 2×k 表并采用自由度为 \( k - 1 \) 的卡方检验。<sup>[5](https://www.mdpi.com/2227-7390/14/9/1449)</sup> 对于小样本，离散列联表概率可能与连续卡方近似相差较大，因此连续性校正（与 Yates 相关）能给出对费希尔精确检验更好的近似；观测数约少于 20 或样本严重不平衡时，通常首选费希尔精确检验。<sup>[6](https://www.statistics4u.com/fundstat_eng/ee_mediantest.html)</sup> 当恰好有两个样本时，SciPy 默认应用 Yates 校正，其 lambda_ 参数允许用任何 Cressie-Read 幂散度统计量替代 Pearson 卡方。<sup>[8](https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.median%5Ftest.html)</sup>

若干修正放宽了标准假设。一种修正版本在不假定总体形状相同的情况下比较中位数，处理广义 Behrens–Fisher 问题。<sup>[5](https://www.mdpi.com/2227-7390/14/9/1449)</sup> 一种结值调整版本在结构上对结值观测调整统计量，去掉了总体必须连续的要求，并允许数据低至序数尺度；它还能识别出是哪个总体导致了拒绝，而标准两样本检验无法做到这一点，且未调整的结值可能严重损害效能。<sup>[10](https://cmhrj.com/index.php/cmhrj/article/view/414)</sup> 对于生存数据，该检验通过一种列联表方法扩展，即按组计数大于合并样本中位数估计值的元素。<sup>[11](https://pmc.ncbi.nlm.nih.gov/articles/PMC4281497/)</sup> robnptests R 包实现了一种基于样本中位数之差的两样本中位数检验，提供渐近、置换和随机化 p 值；当两个样本的观测数均少于 30 时，它默认使用置换或随机化，当两者均不少于 30 时默认使用渐近正态近似。<sup>[12](https://rdrr.io/cran/robnptests/man/med_test.html)</sup>

## 应用

该检验适用于参数假设不成立的场合：违反单因素方差分析或两样本 t 检验正态性假设的非正态数据，<sup>[3](https://www.jmp.com/en/statistics-knowledge-portal/inferential-statistics/hypothesis-testing/median-test)</sup> 以及序数或粗略测量的数据，因为测量尺度只需至少为序数尺度。<sup>[4](https://www.itl.nist.gov/div898/software/dataplot/refman1/auxillar/meditest.htm)</sup> 它在截断或“超出量程”数据中有独特的一席之地，即某些观测值超出仪器量程：在这种情况下，中位数比较别无替代，即使对区间尺度测量也应使用该检验。<sup>[7](https://mvpprograms.com/help/mvpstats/nonparametric-tests)</sup> 模拟研究还建议对具有某些离群值的分布考虑使用它。<sup>[13](https://files.eric.ed.gov/fulltext/ED078002.pdf)</sup>

## 局限与替代方法

主要批评是效能低。一项蒙特卡洛研究发现，对于平坦（类均匀）总体，中位数检验在所有样本量组合下的效能都明显低于其他任何统计量；尽管它对双指数分布在秩检验中具有最高的局部效能，但在模拟中表现很差，仅在 \( n = m = 20 \) 时与 t 统计量和 U 统计量相当。<sup>[13](https://files.eric.ed.gov/fulltext/ED078002.pdf)</sup> 后来的一项效能模拟得出了类似结论，发现即使对双指数分布，其效能也明显低于其他现成的秩检验，并建议将该检验从常规使用中“退休”，转而采用在一大类对称分布上效能更优的秩检验。<sup>[14](https://doi.org/10.1080/00031305.2000.10474539)</sup> 与参数检验相比，其效能总体上相当低。<sup>[6](https://www.statistics4u.com/fundstat_eng/ee_mediantest.html)</sup>

实际检验的假设也与其名称所暗示的不同。此前提出的等中位数检验均源自这样的原假设：每个样本具有相同分布，或具有同一类分布但位置可能不同；当分布形状不同时，这一假设限制了它们的有效性。<sup>[15](https://pmc.ncbi.nlm.nih.gov/articles/PMC4005606/)</sup> 相比之下，Wilcoxon–Mann–Whitney 检验仅在两组仅位置不同时才是等中位数检验；该统计量估计成对概率指数 \( \mathrm{Prob}(X > Y) + 0.5\,\mathrm{Prob}(X = Y) \)，但标准检验的通常原假设校准要求分布相等，因此当分布形状不同时检验该指数是否为 0.5，需要采用适当的方差方法，例如 Brunner–Munzel 型检验。<sup>[16](https://link.springer.com/article/10.1186/1471-2288-12-78)</sup> 为使卡方近似有效，Conover 建议从分析中剔除所有仅含一个观测值的样本。<sup>[4](https://www.itl.nist.gov/div898/software/dataplot/refman1/auxillar/meditest.htm)</sup>

## References

1. [Median Test, The SAGE Encyclopedia of Educational Research, Measurement, and Evaluation](https://methods.sagepub.com/ency/edvol/sage-encyclopedia-of-educational-research-measurement-evaluation/chpt/median-test#_)
2. [ST551 Lecture 25: Other two sample comparisons, Oregon State University](https://st551.cwick.co.nz/lecture/lecture_25/)
3. [Median Test, JMP Statistics Knowledge Portal](https://www.jmp.com/en/statistics-knowledge-portal/inferential-statistics/hypothesis-testing/median-test)
4. [MEDIAN TEST, NIST/SEMATECH e-Handbook of Statistical Methods (Dataplot reference manual)](https://www.itl.nist.gov/div898/software/dataplot/refman1/auxillar/meditest.htm)
5. [Estimating Effect Size for Mood's Median Test (Mathematics, MDPI, 2026)](https://www.mdpi.com/2227-7390/14/9/1449)
6. [Median Test, Statistics4U Fundamentals of Statistics](https://www.statistics4u.com/fundstat_eng/ee_mediantest.html)
7. [MVPstats Help, Nonparametric Tests](https://mvpprograms.com/help/mvpstats/nonparametric-tests)
8. [scipy.stats.median_test, SciPy v1.18.0 Manual](https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.median%5Ftest.html)
9. [Mood's Median Test, R Handbook](https://rcompanion.org/handbook/F_09.html)
10. [Intrinsically Ties Adjusted Median Test for Determining the Lengths of Hospitalization of Sampled Patients with Hypertension and Malaria](https://cmhrj.com/index.php/cmhrj/article/view/414)
11. [Median Tests for Censored Survival Data; a Contingency Table Approach](https://pmc.ncbi.nlm.nih.gov/articles/PMC4281497/)
12. [med_test: Two-sample location tests based on the sample median (robnptests R package)](https://rdrr.io/cran/robnptests/man/med_test.html)
13. [Relative Power of the Mann-Whitney Statistic, the t-Statistic, the Median Test, and Tests Based on Exceedances (Monte Carlo study, ERIC ED078002)](https://files.eric.ed.gov/fulltext/ED078002.pdf)
14. [Should the Median Test be Retired from General Use?](https://doi.org/10.1080/00031305.2000.10474539)
15. [A Nonparametric Test for Equality of Survival Medians](https://pmc.ncbi.nlm.nih.gov/articles/PMC4005606/)
16. [t-tests, non-parametric tests, and large studies, a paradox of statistical practice? (BMC Medical Research Methodology, 2012)](https://link.springer.com/article/10.1186/1471-2288-12-78)

---
*Initially written Sep 29, 2026 · Edited: Oct 15, 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/median-test

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