KendallTau[v1,v2]
对于向量 v1 和 v2,给出 Kendall 的阶数相关性系数
.
KendallTau[m]
对于矩阵 m,给出 Kendall 的阶数相关性系数
.
KendallTau[m1,m2]
对于矩阵 m1 和 m2,给出 Kendall 的阶数相关性系数
.
KendallTau[dist]
对于多变量符号式分布 dist,给出 Kendall 的阶数相关性矩阵.
KendallTau[dist,i,j]
对于多变量符号式分布 dist,给出第
Kendall 阶数相关性.
KendallTau
KendallTau[v1,v2]
对于向量 v1 和 v2,给出 Kendall 的阶数相关性系数
.
KendallTau[m]
对于矩阵 m,给出 Kendall 的阶数相关性系数
.
KendallTau[m1,m2]
对于矩阵 m1 和 m2,给出 Kendall 的阶数相关性系数
.
KendallTau[dist]
对于多变量符号式分布 dist,给出 Kendall 的阶数相关性矩阵.
KendallTau[dist,i,j]
对于多变量符号式分布 dist,给出第
Kendall 阶数相关性.
更多信息
- KendallTau[v1,v2] 给出位于 v1 和 v2 之间的 Kendall 的阶数相关性系数
. - Kendall 的
是基于两个列表的连续元素的相对顺序的单调关联性测量. - 位于
和
之间的 Kendall 的
由
给出,其中
是一致的观测数对,
是不一致的对的数目,
是只涉及
变量的等值数目,而
是只涉及
变量的等值数目. - 一致的观测数对
和
同时满足
和
或者同时满足
和
. 不一致的观测数对同时满足
和
或者同时满足
和
. - 返回的 Kendall 的
的等值校验版本有时候称为 Kendall
的 Tau-b. - 参数 v1 和 v2 可以是相等长度的任意实值向量.
- 对于具有
列的矩阵 m,KendallTau[m] 是由位于 m 的列之间的阶数相关性组成的
×
矩阵. - 对于
×
矩阵 m1 和
×
矩阵 m2,KendallTau[m1,m2] 是由位于 m1 的列之间和 m2 的列之间的阶数相关性组成的
×
矩阵. - KendallTau[dist,i,j] 是一致概率减去偏差概率 Probability[(x1-x2)(y1-y2)>0,{{x1,y1}disti,j,{x2,y2}disti,j}]-Probability[(x1-x2)(y1-y2)<0,{{x1,y1}disti,j,{x2,y2}disti,j}] 其中 disti,j 是 dist 的第
边缘分布. - KendallTau[dist] 给出矩阵
,其中第
元素是由 KendallTau[dist,i,j] 给出的.
范例
打开所有单元 关闭所有单元基本范例 (4)
v1 = {3, -4, 1, 4, 22, 17, -2, 2, 13, -11};
v2 = {-20, -24, 0, 4, 24, 36, -12, -12, 56, -14};KendallTau[v1, v2]m = RandomVariate[BinormalDistribution[.6], 10^3];KendallTau[m]//MatrixFormm1 = RandomReal[1, {10^3, 4}];m2 = RandomReal[1, {10^3, 3}];KendallTau[m1, m2]//MatrixForm𝒟 = BinormalDistribution[.5];KendallTau[𝒟]//MatrixFormKendallTau[RandomVariate[𝒟, 10^4]]//MatrixForm范围 (7)
数据 (4)
KendallTau[{5, 3 / 4, 12}, {2, 1 / 2, 1}]KendallTau[{1.5, 3, 5, 10}, {2, 1.25, 15, 8}]KendallTau[N[{1, 3, 5, 6, 6}, 30], N[{2, -1, 6, 8, 9}, 30]]KendallTau[RandomReal[1, 10 ^ 4], RandomReal[1, 10 ^ 4]]可以使用 SparseArray 数据:
KendallTau[SparseArray[{{2, 2} -> 1, {5, 3} -> 2, {10, 1} -> 3}]]//MatrixForm分布和过程 (3)
KendallTau[BinormalDistribution[ρ]]//MatrixFormKendallTau[BinormalDistribution[ρ], 1, 2]KendallTau[ProductDistribution[ExponentialDistribution[1], NormalDistribution[3, 5]]]//MatrixForm𝒟 = CopulaDistribution[{"Frank", 2}, {UniformDistribution[{0, 1}], UniformDistribution[{0, 1}]}];KendallTau[𝒟]//MatrixForm𝒟 = HistogramDistribution[RandomVariate[BinormalDistribution[.15], 10 ^ 2]];KendallTau[𝒟]//MatrixFormKendallTau[BinormalDistribution[.15]]//MatrixFormKendallTau[WienerProcess[][{0.2, 0.3}]]//MatrixForm应用 (4)
{v11, v21} = Transpose[RandomVariate[BinormalDistribution[.99], 1000]];
{v12, v22} = Transpose[RandomVariate[BinormalDistribution[0], 1000]];KendallTau[v11, v21]KendallTau[v12, v22]data = BlockRandom[SeedRandom[1];Table[RandomVariate[BinormalDistribution[i], 1000], {i, {-.99, -.75, -.25, -.5, 0., .25, .5, .75, .99}}]];Grid[Partition[Table[ListPlot[i, PlotStyle -> Directive[PointSize[Tiny]],
FrameTicks -> None, Frame -> True, Axes -> None, PlotLabel -> Row[{"ρ : ", KendallTau[i][[1, 2]]}]], {i, data}],
3]]uni = RandomReal[{-3, 3}, 1000];f[x_] := {{x, -Sqrt[Abs[x]] + RandomReal[.5]}, {x, .25x^2 + RandomReal[.5]}, {x, -Sinc[x] + RandomReal[.5]}, {Cos[x], Sin[x] + RandomReal[.5]}}data = f /@ uni;Table[ListPlot[data[[All, i]], Frame -> True, Axes -> None, PlotLabel -> Row[{"ρ : ", KendallTau[data[[All, i]]][[1, 2]]}], PlotStyle -> Directive[PointSize[Tiny]], FrameTicks -> None], {i, 4}]HoeffdingD 可用于检测其他独立性结构:
Table[HoeffdingD[data[[All, i]]][[1, 2]], {i, 4}]在 506 个波士顿郊区测量一系列因子,确定这些因素与房屋价值的相关性. 例如氮氧化物浓度和房屋价值中位数之类的因素之间的强关联表明相关性并不意味着因果关系:
ExampleData[{"Statistics", "BostonHomes"}, "LongDescription"]data = ExampleData[{"Statistics", "BostonHomes"}][[All, {3, 5, 14}]];labs = {"Industrial Percentage", "Nitrogen Oxide Conc.", "Median Home Value"};散点图矩阵比较非零售业务、氮氧化物浓度、房屋价值中位数的比例:
GraphicsGrid[Table[If[i == j, Style[labs[[i]], Bold, FontSize -> 12], ListPlot[Transpose[{data[[All, j]], data[[All, i]]}], Frame -> True, Axes -> None, AspectRatio -> 1, FrameTicks -> None, PlotStyle -> PointSize[.01], ImageSize -> {100, 100}, PlotRange -> All]], {i, 3}, {j, 3}]]KendallTau[data]//MatrixFormKendallTauTest 说明氮氧化物的浓度增加时,房屋价值下降:
KendallTauTest[data[[All, 2]], data[[All, 3]], "TestDataTable"]属性和关系 (8)
对于高负相关和高正相关,Kendall 的
范围分别为 -1 到 1:
d1 = RandomVariate[NormalDistribution[], 100];
d2 = -d1;KendallTau[d1, d1]KendallTau[d1, d2]ktau = KendallTau[RandomVariate[BinormalDistribution[1 / 3], 10 ^ 3]];SymmetricMatrixQ[ktau]data = RandomInteger[{-3, 3}, {100, 15}];Diagonal[KendallTau[data]]Kendall 的
与 SpearmanRho 相关:
data = BlockRandom[SeedRandom[1];Table[RandomVariate[BinormalDistribution[i], 2000], {i, {-.99, -.75, -.25, -.5, 0., .25, .5, .75, .99}}]];给定弱线性相关,SpearmanRho 大约趋向于
:
Grid[Partition[Table[ListPlot[i, PlotStyle -> Directive[PointSize[Tiny]],
FrameTicks -> None, Frame -> True, Axes -> None,
PlotLabel -> Row[{"ρ / τ : ", (SpearmanRho[i][[1, 2]]/KendallTau[i][[1, 2]])}]], {i, data}],
3]]使用 KendallTauTest 来测试独立性:
data = RandomVariate[BinormalDistribution[.5], 1000];ListPlot[data, PlotStyle -> Directive[PointSize[Small]], PlotLabel -> KendallTauTest[Sequence@@Transpose[data], "TestDataTable"]]或者,使用 IndependenceTest 来自动选择适当的测试方法:
IndependenceTest[Sequence@@Transpose[data], "TestDataTable"]如果变量很好地单调相关,Kendall 的
将保持 1 或者 -1:
x = RandomReal[{-1, 1}, 1000];
y = ArcTanh[x];
z = -ArcTanh[x];ListPlot[{Transpose[{x, y}], Transpose[{x, z}]}]KendallTau[x, y]KendallTau[x, z]与 Correlation 相反,它严格测量线性相关性:
Correlation[x, y]Correlation[x, z]𝒟 = CopulaDistribution[{"AMH", 2 / 3}, {UniformDistribution[{0, 1}], UniformDistribution[{0, 1}]}];KendallTau[𝒟]Probability[(Subscript[x, 1] - Subscript[x, 2])(Subscript[y, 1] - Subscript[y, 2]) > 0, {{Subscript[x, 1], Subscript[y, 1]}𝒟, {Subscript[x, 2], Subscript[y, 2]}𝒟}] - Probability[(Subscript[x, 1] - Subscript[x, 2])(Subscript[y, 1] - Subscript[y, 2]) < 0, {{Subscript[x, 1], Subscript[y, 1]}𝒟, {Subscript[x, 2], Subscript[y, 2]}𝒟}]% - %%[[1, 2]]//FullSimplify𝒟 = CopulaDistribution[{"FGM", 1 / 2}, {DiscreteUniformDistribution[{0, 5}], DiscreteUniformDistribution[{0, 5}]}];KendallTau[𝒟, 1, 2]dist = {Distributed[{Subscript[x, 1], Subscript[y, 1]}, 𝒟], Distributed[{Subscript[x, 2], Subscript[y, 2]}, 𝒟]};nc = Probability[(Subscript[x, 1] - Subscript[x, 2])(Subscript[y, 1] - Subscript[y, 2]) > 0, dist];
nd = Probability[(Subscript[x, 1] - Subscript[x, 2])(Subscript[y, 1] - Subscript[y, 2]) < 0, dist];
nx = Probability[Boole[Subscript[x, 1] == Subscript[x, 2]∧Subscript[y, 1] ≠ Subscript[y, 2]], dist];
ny = Probability[Boole[Subscript[y, 1] == Subscript[y, 2]∧Subscript[x, 1] ≠ Subscript[x, 2]], dist];tauExpected = (nc - nd) / Sqrt[(nc + nd + nx) (nc + nd + ny)]data = RandomVariate[𝒟, 5 * 10^4];tauSim = KendallTau[data]tauExpected - tauSim[[1, 2]]//N(nc - nd) - tauSim[[1, 2]]//N文本
Wolfram Research (2012),KendallTau,Wolfram 语言函数,https://reference.wolfram.com/language/ref/KendallTau.html.
CMS
Wolfram 语言. 2012. "KendallTau." Wolfram 语言与系统参考资料中心. Wolfram Research. https://reference.wolfram.com/language/ref/KendallTau.html.
APA
Wolfram 语言. (2012). KendallTau. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/ref/KendallTau.html 年
BibTeX
@misc{reference.wolfram_2026_kendalltau, author="Wolfram Research", title="{KendallTau}", year="2012", howpublished="\url{https://reference.wolfram.com/language/ref/KendallTau.html}", note=[Accessed: 01-August-2026]}
BibLaTeX
@online{reference.wolfram_2026_kendalltau, organization={Wolfram Research}, title={KendallTau}, year={2012}, url={https://reference.wolfram.com/language/ref/KendallTau.html}, note=[Accessed: 01-August-2026]}