Wolfram Language

Extended Probability & Statistics

Multivariate Normality Test

BaringhausHenzeTest is a multivariate normality test with the test statistic based on the empirical characteristic function. It is also known as the BaringhausHenzeEppsPulley (BHEP) test.

In[1]:=
Click for copyable input
data = RandomVariate[NormalDistribution[], {10^3, 3}];
In[2]:=
Click for copyable input
BaringhausHenzeTest[data]
Out[2]=

The test statistic is invariant under affine transformations of the data.

In[3]:=
Click for copyable input
data2 = AffineTransform[{RandomReal[1, {3, 3}], RandomReal[1, 3]}][ data]; {BaringhausHenzeTest[data2, "TestStatistic"], BaringhausHenzeTest[data, "TestStatistic"]}
Out[3]=

The test statistic is also consistent against every alternative distributionthat is, it grows unboundedly with the sample size unless the data comes from a Gaussian distribution.

In[4]:=
Click for copyable input
covm = {{2, 1, 0}, {1, 3, -1}, {0, -1, 2}}; ng\[ScriptCapitalD] = MultivariateTDistribution[covm, 12]; g\[ScriptCapitalD] = MultinormalDistribution[{0, 0, 0}, covm];

Draw samples from a multivariate t distribution and a multivariate normal distribution.

In[5]:=
Click for copyable input
nongaussianData = RandomVariate[ng\[ScriptCapitalD], 2^14]; gaussianData = RandomVariate[g\[ScriptCapitalD], 2^14];

Compute and visualize the BHEP test statistics as a function of sample size.

In[6]:=
Click for copyable input
sizes = 2^Range[3, 14]; {nonGaussianTestStatistic, GaussianTestStatistic} = ParallelTable[{size, BaringhausHenzeTest[Take[d, size], "TestStatistic"]}, {d, {nongaussianData, gaussianData}}, {size, sizes}];
show complete Wolfram Language input
In[7]:=
Click for copyable input
ListLogLogPlot[{nonGaussianTestStatistic, GaussianTestStatistic}, PlotLegends -> {"Non-Gaussian", "Gaussian"}, ImageSize -> Medium, PlotRange -> All, FrameLabel -> {n, Subscript[T, n]}, PlotTheme -> "Detailed", Joined -> True]
Out[7]=

Related Examples

de es fr ja ko pt-br ru zh