# 独立性检验（统计学）

独立性检验是一种统计假设检验，用样本数据评估两个变量或随机向量是否在统计上独立，从而拒绝或无法拒绝“联合分布等于其边缘分布之乘积”这一零假设。实践中的困难在于，相依性可以是任意形状的：皮尔逊相关只度量线性关系，秩相关只度量单调关系，因此一个对所有备择假设都有效的检验必须能探测任意形状的结构。<sup>[1](https://journals.sagepub.com/doi/10.1177/0962280215594198)</sup> 现有方法涵盖列联表检验、基于秩的统计量、互信息准则、距离协方差，以及诸如希尔伯特–施密特独立性准则（HSIC）这样的核度量。<sup>[2](https://openresearch-repository.anu.edu.au/items/dbf2c897-46a5-4442-a049-2ddcd83f3352/full)</sup>

| 关键事实 | 细节 |
|---|---|
| 零假设 | 联合分布 \( P_{XY} \) 等于边缘分布之乘积 \( P_X \cdot P_Y \)；当相依性统计量较大时拒绝零假设。 |
| 距离协方差 | \( V^2(X,Y) = \|f_{X,Y}(t,s) - f_X(t) \cdot f_Y(s)\|^2 \) 对权重函数积分；对于一阶矩有限的变量，当且仅当 \(X\) 与 \(Y\) 独立时为零。<sup>[3](https://pages.stat.wisc.edu/~wahba/stat860/pdf1/szekely.rizzo.bakirov.2007.pdf)</sup> |
| HSIC | 再生核希尔伯特空间中交叉协方差算子的经验希尔伯特–施密特范数；当各再生核希尔伯特空间具有通用性时，当且仅当独立时为零。<sup>[2](https://openresearch-repository.anu.edu.au/items/dbf2c897-46a5-4442-a049-2ddcd83f3352/full)</sup> |
| 等价性 | 距离协方差恰好是采用距离诱导核的 HSIC，且当再生核希尔伯特空间具有特征性时，两者对所有备择假设都是一致的。<sup>[4](https://arxiv.org/pdf/1207.6076v3.pdf)</sup> |
| 零分布 | 置换是标准的校准方式；Gamma 近似与卡方近似以精确性换取速度。<sup>[5](https://papers.nips.cc/paper/2007/file/d5cfead94f5350c12c322b5b664544c1-Paper.pdf)</sup> |
| 计算代价 | 标准的 HSIC 与 dCov 检验在样本量为 \(m\) 时至少需要 \( O(m^2) \) 的时间和存储。<sup>[6](https://link.springer.com/article/10.1007/s11222-016-9721-7)</sup> |
| 条件独立性 | 对于连续变量，若不加额外假设，不存在对任意备择假设都有功效的有效条件独立性检验。<sup>[7](https://arxiv.org/html/1804.07203)</sup> |

## 工作原理

每一种独立性检验都可归结为一个问题：观测到的联合分布是否与独立情形下应产生的分布不同？零假设是 \( P_{XY} = P_X \cdot P_Y \)，但并非每种方法都能探测每一个相依的备择假设：皮尔逊相关对于相依变量也可能为零，而距离相关在一阶矩有限的假设下，当且仅当变量独立时为零。<sup>[23](https://pmc.ncbi.nlm.nih.gov/articles/PMC4539721/)</sup>

不同的泛函，同一个目标。皮尔逊卡方检验与 G 检验度量列联表中观测频数与期望频数之间的差异。距离协方差度量联合分布的特征函数与边缘特征函数之乘积之间的加权 \( L_2 \) 距离。<sup>[3](https://pages.stat.wisc.edu/~wahba/stat860/pdf1/szekely.rizzo.bakirov.2007.pdf)</sup> HSIC 在将两个变量嵌入再生核希尔伯特空间之后，估计交叉协方差算子的希尔伯特–施密特范数；这可解释为一种与联合密度和乘积密度之间的 KL 散度 \( D_{\mathrm{KL}}(p_{x,y} \| p_x p_y) \) 相关的核度量。<sup>[2](https://openresearch-repository.anu.edu.au/items/dbf2c897-46a5-4442-a049-2ddcd83f3352/full)</sup> 塞迪诺维奇、斯里佩伦布杜尔、格雷顿与福水（Sejdinovic, Sriperumbudur, Gretton and Fukumizu）证明了 \(X\) 与 \(Y\) 的 HSIC 是 \( P_{XY} \) 与 \( P_X \cdot P_Y \) 之间的最大均值差异，而距离协方差是采用距离诱导核的特例。<sup>[4](https://arxiv.org/pdf/1207.6076v3.pdf)</sup>

核方法与距离方法之所以对所有备择假设都有效，原因在于特征核（即其嵌入能区分所有概率分布的核）条件：当再生核希尔伯特空间具有特征性时（例如使用高斯核），概率测度的嵌入是单射，因此统计量当且仅当独立时为零，检验对每一个固定的备择假设都是一致的。<sup>[4](https://arxiv.org/pdf/1207.6076v3.pdf)</sup> 基于秩的检验以不同方式获得更广泛的敏感性：霍夫丁 D 近似为 2×2 表上卡方统计量的加权和，能探测超出单调相依的偏离，尽管并列值会降低其取值。<sup>[1](https://journals.sagepub.com/doi/10.1177/0962280215594198)</sup>

## 实施方法

对于分类数据，将观测交叉分类为列联表，比较观测频数与期望频数。对于连续数据，典型流程是：选择一个相依性统计量（dCov、HSIC、秩统计量或基于信息的度量）；在样本上计算它；获得零分布参照；若统计量超过 \( 1-\alpha \) 分位数，则在水平 \(\alpha\) 下拒绝零假设。

零分布参照是难点所在。有偏的经验 HSIC 估计量是一个 V 统计量，相应的无偏 U 统计量在零假设下是退化的，m 倍有偏统计量收敛于独立卡方变量的无穷加权和，这正是通常采用置换检验的原因。<sup>[8](https://www.jmlr.org/papers/v24/23-0248.html)</sup> 置换检验将样本统计量与置换 \(Y\) 的行之后计算出的 \(r\) 个统计量进行比较，\(r\) 至少取 100，这使得它在大数据上速度很慢。<sup>[9](https://ar5iv.labs.arxiv.org/html/1806.05514)</sup> 更快的替代方法包括格雷顿及其同事提出的 Gamma 近似，它将经验 HSIC 与近似的渐近零分布分位数进行比较。<sup>[5](https://papers.nips.cc/paper/2007/file/d5cfead94f5350c12c322b5b664544c1-Paper.pdf)</sup>

## 起源

这一问题有着悠久的谱系。瓦西里·霍夫丁（Wassily Hoeffding）于 1948 年在《数学统计年鉴》上发表了《独立性的一种非参数检验》，提出了一个对每个固定备择假设都具有渐近功效的基于秩的检验。<sup>[10](https://doi.org/10.1214/aoms/1177730150)</sup> A. 雷尼（A. Rényi）于 1959 年在《匈牙利科学院数学学报》上发表的《论相依性的度量》一文，通过泛函相关来框定相依性度量。<sup>[11](https://doi.org/10.1007/bf02024507)</sup> 基于核的相依性度量源自核独立成分分析与一种二次相依性度量，二者在 HSIC 论文的参考文献列表中均被列为先驱工作。<sup>[12](http://dl.acm.org/doi/10.1007/11564089_7)</sup> HSIC 度量本身由阿瑟·格雷顿（Arthur Gretton）及其同事在 2005 年算法学习理论会议上提出。<sup>[12](http://dl.acm.org/doi/10.1007/11564089_7)</sup> 加博尔·J. 塞凯利（Gábor J. Székely）、玛丽亚·L. 里佐（Maria L. Rizzo）与纳伊尔·K. 巴基罗夫（Nail K. Bakirov）于 2007 年在《统计年鉴》上发表了距离协方差框架。<sup>[3](https://pages.stat.wisc.edu/~wahba/stat860/pdf1/szekely.rizzo.bakirov.2007.pdf)</sup> 大卫·N. 雷谢夫（David N. Reshef）及其同事于 2011 年在《科学》上提出了最大信息系数<sup>[13](https://doi.org/10.1126/science.1205438)</sup>，托马斯·B. 贝雷特（Thomas B. Berrett）与理查德·J. 萨姆沃思（Richard J. Samworth）于 2021 年在《皇家学会会刊 A》上发表了 USP 检验。<sup>[14](https://royalsocietypublishing.org/rspa/article-pdf/doi/10.1098/rspa.2021.0549/355714/rspa.2021.0549.pdf)</sup>

## 变体

**列联表检验与秩检验。** 皮尔逊卡方检验与 G 检验是最常见的表格检验，但当单元格计数较低时，两者都可能无法控制第一类错误，而皮尔逊统计量的设计初衷是针对低概率单元格中的偏离具有功效，恰恰在这些地方其卡方校准不可信。<sup>[14](https://royalsocietypublishing.org/rspa/article-pdf/doi/10.1098/rspa.2021.0549/355714/rspa.2021.0549.pdf)</sup> USP 检验是一种 U 统计量置换检验，对每个 \( n \ge 4 \) 都在名义水平上控制第一类错误，能处理零单元格计数，并能探测其相依性度量以极小极大最优速率 \( C \cdot n^{-1} \) 衰减的备择假设。<sup>[14](https://royalsocietypublishing.org/rspa/article-pdf/doi/10.1098/rspa.2021.0549/355714/rspa.2021.0549.pdf)</sup>

**基于信息的度量。** 最大信息系数（MIC）在网格上最大化一个类互信息量，网格大小 \( B(n) \) 通常设为 \( n^{0.6} \)；其取值从独立时的 0 到无噪声函数关系时的 1，仅适用于二元数据，且在某些噪声水平下可能漏掉线性相依。<sup>[1](https://journals.sagepub.com/doi/10.1177/0962280215594198)</sup> 原始的 MIC 统计量没有已知的多项式时间算法；MICe 是总体量 MIC* 的一个一致且可高效计算的估计量，而当 \( \omega(1) < B(n) \le O(n^{1-\varepsilon}) \) 时，TICe 给出独立性的一致检验。<sup>[15](https://jmlr.csail.mit.edu/papers/volume17/15-308/15-308.pdf)</sup>

**核与距离变体。** 尼克拉斯·菲斯特（Niklas Pfister）、彼得·比尔曼（Peter Bühlmann）、伯恩哈德·舍尔科普夫（Bernhard Schölkopf）与约纳斯·彼得斯（Jonas Peters）提出的 d 变量 HSIC（dHSIC）将 HSIC 推广到任意数量 \(d\) 个变量的联合独立性，定义为联合嵌入与边缘嵌入之乘积之间的平方再生核希尔伯特空间距离。<sup>[16](https://stat.ethz.ch/Manuscripts/buhlmann/dhsic.pdf)</sup> HSIC 的线性时间估计量包括基于块、奈斯特罗姆（Nyström）以及随机傅里叶特征的版本。<sup>[6](https://link.springer.com/article/10.1007/s11222-016-9721-7)</sup> xHSIC 与 xdCov 通过样本分裂与学生化对 HSIC 和距离协方差加以改造，使零分布为标准高斯分布，从而免去置换，其功效在置换检验的常数因子之内，并且对光滑局部备择假设具有极小极大速率最优性。<sup>[8](https://www.jmlr.org/papers/v24/23-0248.html)</sup>

## 应用

HSIC 已被应用于聚类、特征选择、因果推断与计算语言学。<sup>[6](https://link.springer.com/article/10.1007/s11222-016-9721-7)</sup> 另一个应用领域是因果发现：dHSIC 通过检验残差是否联合独立来验证拟合的结构因果模型。<sup>[16](https://stat.ethz.ch/Manuscripts/buhlmann/dhsic.pdf)</sup> 张坤（Kun Zhang）、约纳斯·彼得斯、多米尼克·扬青（Dominik Janzing）与伯恩哈德·舍尔科普夫提出的 KCI 检验，无需密度估计即可导出条件独立性的渐近零分布<sup>[17](https://doi.org/10.48550/arxiv.1202.3775)</sup>；RCIT 与 RCoT 用随机傅里叶特征对其加以近似，在实践中随样本量线性扩展。<sup>[18](https://doi.org/10.1515/jci-2018-0017)</sup> 贝雷特、王、福伊格尔·巴伯与萨姆沃思提出的条件置换检验对 \(X\) 的元素进行非均匀置换，以尊重 \(X\) 与 \(Z\) 之间的相依性，并具有有限样本下的第一类错误控制。<sup>[19](https://doi.org/10.1111/rssb.12340)</sup>

## 局限与替代方法

**高维。** 在高维情形下，样本距离或 HSIC 协方差被近似为逐分量交叉协方差平方和，因此标准的联合检验只能捕捉线性相依；塞凯利与里佐（2013）的距离相关 t 检验，在向量非线性相依但逐分量不相关时，极限功效仅等于检验水平。<sup>[20](https://par.nsf.gov/servlets/purl/10227453)</sup>

**样本量与核的选择。** 即使在 HSIC、距离相关与 RDC 中，也观察到在 \( n = 250 \) 与 \( n = 500 \) 时功效不佳，这表明在针对独立性的功效与公平性之间存在权衡。<sup>[21](https://web.mit.edu/dnreshef/www/websiteFiles/Papers/AOAS-2018.pdf)</sup>

**条件独立性。** 对于条件独立性检验，沙阿与彼得斯（Shah and Peters）证明了，在连续分布数据下，任何有效检验若其水平低于预先设定的水平，则对任何备择假设都没有功效，因此额外假设不可避免<sup>[7](https://arxiv.org/html/1804.07203)</sup>；他们的广义协方差度量将 \(X\) 对 \(Z\) 回归、\(Y\) 对 \(Z\) 回归，并检验归一化后的残差协方差。<sup>[7](https://arxiv.org/html/1804.07203)</sup>

**校准代价。** Gamma 近似的 HSIC 检验仅在小维度下表现良好，在高维下会失效或变得非常保守，而置换检验的耗时约为其 100 到 1000 倍。<sup>[22](https://arxiv.org/html/2301.00967v1)</sup> 对 HSIC 统计量的三累积量匹配卡方近似代价为 \( O(n^3) \)，免去置换，并能处理多变量、高维与函数型数据。<sup>[22](https://arxiv.org/html/2301.00967v1)</sup>

## References

1. [Dependence and independence: Structure and inference (Statistical Methods in Medical Research)](https://journals.sagepub.com/doi/10.1177/0962280215594198)
2. [Kernel methods for measuring independence (Gretton, Herbrich, Smola, Bousquet, Schölkopf), JMLR 6 (2005): 2075-2129](https://openresearch-repository.anu.edu.au/items/dbf2c897-46a5-4442-a049-2ddcd83f3352/full)
3. [Measuring and testing dependence by correlation of distances (Székely, Rizzo & Bakirov, Annals of Statistics 2007)](https://pages.stat.wisc.edu/~wahba/stat860/pdf1/szekely.rizzo.bakirov.2007.pdf)
4. [Equivalence of distance-based and RKHS-based statistics in hypothesis testing (Sejdinovic, Sriperumbudur, Gretton, Fukumizu)](https://arxiv.org/pdf/1207.6076v3.pdf)
5. [A Kernel Statistical Test of Independence (Gretton et al., NIPS 2007)](https://papers.nips.cc/paper/2007/file/d5cfead94f5350c12c322b5b664544c1-Paper.pdf)
6. [Large-scale kernel methods for independence testing (Zhang et al., Statistics and Computing)](https://link.springer.com/article/10.1007/s11222-016-9721-7)
7. [The Hardness of Conditional Independence Testing and the Generalised Covariance Measure (Shah & Peters)](https://arxiv.org/html/1804.07203)
8. [A Permutation-Free Kernel Independence Test (xHSIC/xdCov, JMLR 24)](https://www.jmlr.org/papers/v24/23-0248.html)
9. [The Exact Equivalence of Distance and Kernel Methods in Hypothesis Testing (Shen & Vogelstein, 2018)](https://ar5iv.labs.arxiv.org/html/1806.05514)
10. [Wassily Hoeffding (1948). A Non-Parametric Test of Independence. The Annals of Mathematical Statistics.](https://doi.org/10.1214/aoms/1177730150)
11. [A. Rényi (1959). On measures of dependence. Acta Mathematica Academiae Scientiarum Hungaricae.](https://doi.org/10.1007/bf02024507)
12. [Measuring statistical dependence with Hilbert-Schmidt norms, ALT'05 proceedings page (Springer/ACM DL)](http://dl.acm.org/doi/10.1007/11564089_7)
13. [David N. Reshef and colleagues (2011). Detecting Novel Associations in Large Data Sets. Science.](https://doi.org/10.1126/science.1205438)
14. [USP: an independence test that improves on Pearson's chi-squared and the G-test (Proceedings of the Royal Society A)](https://royalsocietypublishing.org/rspa/article-pdf/doi/10.1098/rspa.2021.0549/355714/rspa.2021.0549.pdf)
15. [Measuring Dependence Powerfully and Equitably (JMLR)](https://jmlr.csail.mit.edu/papers/volume17/15-308/15-308.pdf)
16. [Kernel-based tests for joint independence (Pfister, Bühlmann et al., JRSS-B 2018)](https://stat.ethz.ch/Manuscripts/buhlmann/dhsic.pdf)
17. [Zhang, Kun and colleagues (2012). Kernel-based Conditional Independence Test and Application in Causal Discovery. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.1202.3775)
18. [Strobl Eric V., Zhang Kun, Visweswaran Shyam (2019). Approximate Kernel-Based Conditional Independence Tests for Fast Non-Parametric Causal Discovery. DOAJ (DOAJ: Directory of Open Access Journals).](https://doi.org/10.1515/jci-2018-0017)
19. [Thomas B. Berrett and colleagues (2019). The Conditional Permutation Test for Independence While Controlling for Confounders. Journal of the Royal Statistical Society Series B (Statistical Methodology).](https://doi.org/10.1111/rssb.12340)
20. [Distance-based and RKHS-based dependence metrics in high dimension (Annals of Statistics)](https://par.nsf.gov/servlets/purl/10227453)
21. [An empirical study of the maximal and total information coefficients and leading measures of dependence (Annals of Applied Statistics)](https://web.mit.edu/dnreshef/www/websiteFiles/Papers/AOAS-2018.pdf)
22. [A fast and accurate kernel-based independence test with applications to high-dimensional and functional data](https://arxiv.org/html/2301.00967v1)
23. [pmc.ncbi.nlm.nih.gov](https://pmc.ncbi.nlm.nih.gov/articles/PMC4539721/)

---
*Initially written Sep 29, 2026 · Reviewed: Sep 30, 2026 · Edited: Oct 15, 2026 · Last review: Sep 30, 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/independence-test-statistics

English original: https://www.edgepedia.org/independence-test-statistics
