PillaiTrace[m1,m2]
gives Pillai's trace for the matrices m1 and m2.
PillaiTrace
PillaiTrace[m1,m2]
gives Pillai's trace for the matrices m1 and m2.
Details
- PillaiTrace[m1,m2] gives Pillai's trace between m1 and m2.
- Pillai's trace is a measure of linear dependence based on partitions of the pooled covariance matrix.
- Pillai's trace is computed as
where
is the covariance matrix of the pooled sample, which can be partitioned into
where
and
correspond to the covariance matrices of the individual datasets. - The arguments m1 and m2 can be any real‐valued matrices or vectors of equal length.
Examples
open all close allBasic Examples (3)
Compute Pillai's trace for two matrices:
m1 = RandomReal[1, {10^3, 4}];m2 = RandomReal[1, {10^3, 3}];PillaiTrace[m1, m2]Pillai's trace for two vectors:
v1 = {3, -4, 1, 4, 22, 17, -2, 2, 13, -11};
v2 = {-20, -24, 0, 4, 24, 36, -12, -12, 56, -14};PillaiTrace[v1, v2]Pillai's trace for a matrix and a vector:
m = RandomReal[1, {10^3, 4}];v = RandomReal[1, 10^3];PillaiTrace[m, v]Scope (3)
Pillai's trace is typically used to detect linear dependence between random matrices:
Σ1 = IdentityMatrix[5];
Σ2 = {{12.8, 0.3, 3., -1.5, 5.1}, {0.3, 2.4, 0.9, -0.3, -0.8}, {3., 0.9, 6.5, 0.8, 1.3}, {-1.5, -0.3, 0.8, 1.4, 2.}, {5.1, -0.8, 1.3, 2., 11.1}};𝒟 = Table[MultinormalDistribution[ConstantArray[0, 5], Σ], {Σ, {Σ1, Σ2}}];data = RandomVariate[#, 1000]& /@ 𝒟;Values tend to be near
for dependent matrices:
PillaiTrace[data[[2, All, 1 ;; 3]], data[[2, All, 4 ;; 5]]]The value is much smaller for independent matrices:
PillaiTrace[data[[1, All, 1 ;; 3]], data[[1, All, 4 ;; 5]]]Pillai's trace for machine-precision reals:
PillaiTrace[{1.5, 3, 5, 10}, {2, 1.25, 15, 8}]PillaiTrace[N[{1, 3, 5, 6, 6}, 30], N[{2, -1, 6, 8, 9}, 30]]Properties & Relations (4)
Pillai's trace measures linear dependence:
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[{"Pillai : ", PillaiTrace[Sequence@@Transpose[i]]}]], {i, data}],
3]]Pillai's trace cannot detect nonlinear dependency:
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[{"ρ : ", PillaiTrace[Sequence@@Transpose[data[[All, i]]]]}], PlotStyle -> Directive[PointSize[Tiny]], FrameTicks -> None], {i, 4}]HoeffdingD can be used to detect some nonlinear dependence structures:
Table[HoeffdingD[data[[All, i]]][[1, 2]], {i, 4}]Pillai's trace is asymptotically equivalent to WilksW:
ListLinePlot[Table[
d1 = RandomVariate[BinormalDistribution[0], Ceiling[10^i]];
d2 = RandomVariate[BinormalDistribution[0], Ceiling[10^i]];{i, Abs[PillaiTrace[d1, d2] - WilksW[d1, d2]]}, {i, Range[1, 4, .01]}], PlotRange -> All, AxesLabel -> {"SubscriptBox[Log, 10][n]", "Abs[Pillai's tr - 𝒲]"}]Statistical significance can be tested using PillaiTraceTest:
Σ = {{12.8, 0.3, 3., -1.5, 5.1}, {0.3, 2.4, 0.9, -0.3, -0.8}, {3., 0.9, 6.5, 0.8, 1.3}, {-1.5, -0.3, 0.8, 1.4, 2.}, {5.1, -0.8, 1.3, 2., 11.1}};data = RandomVariate[MultinormalDistribution[ConstantArray[0, 5], Σ], 10 ^ 2];PillaiTrace[data[[All, 1 ;; 3]], data[[All, 4 ;; 5]]]PillaiTraceTest[data[[All, 1 ;; 3]], data[[All, 4 ;; 5]], "TestDataTable"]Alternatively, use IndependenceTest to automatically choose a test:
IndependenceTest[data[[All, 1 ;; 3]], data[[All, 4 ;; 5]], "TestDataTable"]Related Guides
History
Text
Wolfram Research (2012), PillaiTrace, Wolfram Language function, https://reference.wolfram.com/language/ref/PillaiTrace.html.
CMS
Wolfram Language. 2012. "PillaiTrace." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/PillaiTrace.html.
APA
Wolfram Language. (2012). PillaiTrace. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/PillaiTrace.html
BibTeX
@misc{reference.wolfram_2026_pillaitrace, author="Wolfram Research", title="{PillaiTrace}", year="2012", howpublished="\url{https://reference.wolfram.com/language/ref/PillaiTrace.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_pillaitrace, organization={Wolfram Research}, title={PillaiTrace}, year={2012}, url={https://reference.wolfram.com/language/ref/PillaiTrace.html}, note=[Accessed: 12-June-2026]}