BaringhausHenzeTest[data]
tests whether data follows a MultinormalDistribution using the Baringhaus–Henze test.
BaringhausHenzeTest[data,MultinormalDistribution[μ,Σ]]
tests whether data follows the distribution with mean vector μ and covariance matrix Σ.
BaringhausHenzeTest[data,"property"]
returns the value of "property".
BaringhausHenzeTest
BaringhausHenzeTest[data]
tests whether data follows a MultinormalDistribution using the Baringhaus–Henze test.
BaringhausHenzeTest[data,MultinormalDistribution[μ,Σ]]
tests whether data follows the distribution with mean vector μ and covariance matrix Σ.
BaringhausHenzeTest[data,"property"]
returns the value of "property".
Details and Options
- BaringhausHenzeTest performs a goodness-of-fit test, with null hypothesis
that data was drawn from a MultinormalDistribution and alternative hypothesis
that it was not. - BaringhausHenzeTest is also known as Baringhaus–Henze–Epps–Pulley multivariate normality test, or BHEP test.
- By default, a probability value or
-value is returned. - A small
-value suggests that it is unlikely that the data came from a multivariate normal distribution. - The data can be univariate {x1,…,xn} or multivariate {{x1,y1,…},…,{xn,yn,…}}.
- The Baringhaus–Henze test effectively uses a test statistic Tβ based on an
distance between the empirical characteristic function of decorrelated standardized data and the standard multivariate Gaussian characteristic function Tβ=Expectation[n Abs[Ψemp[t]-Ψst[t]]2,{t1,…,td}], where =ProductDistribution[{NormalDistribution[0,β],d}]. » - The β parameter is positive and determines the smoothing of the empirical distribution. It is automatically determined, but can be changed using a Method setting.
- BaringhausHenzeTest[data,MultinormalDistribution[μ,Σ],"HypothesisTestData"] returns a HypothesisTestData object htd that can be used to extract additional test results and properties using the form htd["property"].
- BaringhausHenzeTest[data,MultinormalDistribution[μ,Σ],"property"] can be used to directly give the value of "property".
- Properties related to the reporting of test results include:
-
"PValue"
-value"PValueTable" formatted version of "PValue" "ShortTestConclusion" a short description of the conclusion of a test "TestConclusion" a description of the conclusion of a test "TestData" test statistic and
-value"TestDataTable" formatted version of "TestData" "TestStatistic" test statistic "TestStatisticTable" formatted "TestStatistic" - The following properties are independent of which test is being performed.
- Properties related to the data distribution include:
-
"FittedDistribution" fitted distribution of data "FittedDistributionParameters" distribution parameters of data - The following options can be given:
-
Method Automatic the method to use for computing
-valuesSignificanceLevel 0.05 cutoff for diagnostics and reporting - For a test for goodness of fit, a cutoff
is chosen such that
is rejected only if
. The value of
used for the "TestConclusion" and "ShortTestConclusion" properties is controlled by the SignificanceLevel option. By default,
is set to 0.05. » - With the setting Method->"MonteCarlo", a number of datasets of the same length as the input
are generated under
using the fitted distribution. The EmpiricalDistribution from BaringhausHenzeTest[si,"TestStatistic"] is then used to estimate the
-value. » - The setting Method{method,"SmoothingParameter"β} allows for a custom smoothing parameter β. By default,
, in which case the test is also known as the Henze–Zirkler test. »
Examples
open all close allBasic Examples (3)
Perform a test for multivariate normality:
data = RandomVariate[BinormalDistribution[1 / 2], 1000];BaringhausHenzeTest[data]Extract the test statistic from the Baringhaus–Henze test:
data = RandomVariate[MultinormalDistribution[{1, 2, 3}, {{2, 1, 0}, {1, 3, -1}, {0, -1, 1}}], 1000];BaringhausHenzeTest[data, "TestStatistic"]Obtain a formatted test table:
data = RandomVariate[ProductDistribution[BinormalDistribution[2 / 3], BinormalDistribution[-1 / 2]], 1000];BaringhausHenzeTest[data, "TestDataTable"]Scope (6)
Testing (3)
Perform a Baringhaus–Henze test for univariate normality:
data1 = RandomVariate[NormalDistribution[], 1000];
data2 = RandomVariate[StudentTDistribution[4], 1000];The
-value for the normal data is large compared to the
-value for the non-normal data:
BaringhausHenzeTest[data1]BaringhausHenzeTest[data2]Perform a Baringhaus–Henze test for multivariate normality:
data1 = RandomVariate[MultinormalDistribution[{0, 0, 0}, {{3, 2, 1}, {2, 4, 0}, {1, 0, 2}}], 1000];
data2 = RandomVariate[MultivariateTDistribution[{{3, 2, 1}, {2, 4, 0}, {1, 0, 2}}, 6], 1000];The
-value for the normal data is large compared to the
-value for the non-normal data:
BaringhausHenzeTest[data1]BaringhausHenzeTest[data2]Create a HypothesisTestData object for repeated property extraction:
data = RandomVariate[BinormalDistribution[-0.5], 10^3];ℋ = BaringhausHenzeTest[data, "HypothesisTestData"]The properties available for extraction:
ℋ["Properties"]Reporting (3)
Tabulate the results of the Baringhaus–Henze test:
data = RandomVariate[BinormalDistribution[.5], 10^3];ℋ = BaringhausHenzeTest[data, "HypothesisTestData"];ℋ["TestDataTable"]ℋ["PValueTable"]ℋ["TestStatisticTable"]Retrieve the entries from a Baringhaus–Henze test table for custom reporting:
data1 = RandomVariate[BinormalDistribution[.5], 10^3];
data2 = RandomVariate[BinormalDistribution[.5], 10^3];ℋ1 = BaringhausHenzeTest[data1, "TestData"]ℋ2 = BaringhausHenzeTest[data2, "TestData"]BarChart[{Labeled[ℋ1, "Set 1"], Labeled[ℋ2, "Set 2"]}, ChartLabels -> {"Statistic", "p‐value"}]Report test conclusions using "ShortTestConclusion" and "TestConclusion":
data = BlockRandom[SeedRandom[1];RandomVariate[StudentTDistribution[4], {100, 2}]];ℋ = BaringhausHenzeTest[data, "HypothesisTestData"];ℋ["ShortTestConclusion"]ℋ["TestConclusion"]//TraditionalFormThe conclusion may differ at a different significance level:
ℋ = BaringhausHenzeTest[data, "HypothesisTestData", SignificanceLevel -> .001];ℋ["ShortTestConclusion"]ℋ["TestConclusion"]//TraditionalFormOptions (3)
Method (2)
Set the smoothing parameter β used in the Baringhaus–Henze test:
BlockRandom[SeedRandom["fixed"];data = RandomVariate[BinormalDistribution[2 / 3], 1000];]pvls = Table[{beta, BaringhausHenzeTest[data, Method -> {Automatic, "SmoothingParameter" -> beta}]}, {beta, {0.05, 0.1, 0.25, 0.5, 1, 1.5, 2, 3, 5}}];The smoothing parameter β has an effect on the resulting
-value:
ListLinePlot[pvls, FrameLabel -> {"β", "P-Value"}, Frame -> True, AxesOrigin -> {0, 0}, PlotRange -> All]Set the random seed used in Monte Carlo-based methods:
data = RandomVariate[BinormalDistribution[.5], 1000];pts = Table[{i, BaringhausHenzeTest[data, Method -> {"MonteCarlo", "RandomSeed" -> i, "MonteCarloSamples" -> 100}]}, {i, Range[1, 10]}];The seed affects the state of the generator and has some effect on the resulting
-value:
Show[ListLinePlot[pts, PlotRange -> {Min[pts[[All, 2]]], Max[pts[[All, 2]]]}, FrameLabel -> {"Seed", "P-Value"}, Frame -> True, AxesOrigin -> {0, 0}]]Find the
-value using the Monte Carlo method and a custom setting of the test's parameter β:
BaringhausHenzeTest[data, Method -> {"MonteCarlo", "MonteCarloSamples" -> 100, "SmoothingParameter" -> 0.25}]Compare with the
-value obtained with the default method:
BaringhausHenzeTest[data, Method -> {Automatic, "SmoothingParameter" -> 0.25}]SignificanceLevel (1)
Set the significance level used for "TestConclusion" and "ShortTestConclusion":
data = BlockRandom[SeedRandom[2];RandomVariate[StudentTDistribution[5], {100, 2}]];BaringhausHenzeTest[data, "ShortTestConclusion", SignificanceLevel -> .1]BaringhausHenzeTest[data, "ShortTestConclusion", SignificanceLevel -> .25]BaringhausHenzeTest[data, "TestConclusion"]//TraditionalFormApplications (4)
A power (the probability of rejecting
when it is false) curve for the Baringhaus–Henze test:
data = Table[RandomVariate[MultivariateTDistribution[IdentityMatrix[2], 3], {1000, i}], {i, n = Range[10, 50, 5]}];ℋ = Map[BaringhausHenzeTest, data, {2}];pC = Interpolation[Transpose[{n, Table[Probability[x ≤ 0.05, xi], {i, ℋ}]}], InterpolationOrder -> 1];Visualize the approximate power curve:
Plot[pC[x], {x, 10, 50}, PlotRange -> {0, 1}, Ticks -> {n, Automatic}, AxesOrigin -> {7, 0}, AxesLabel -> {"Sample Size", "Power"}]Estimate the power of the Baringhaus–Henze test when the underlying distribution is a MultivariateTDistribution, the test size is 0.05, and the sample size is 43:
pC[43.]Check whether a continuous-time random process is a Gaussian process. Fractional Brownian motion:
proc1 = RandomFunction[FractionalBrownianMotionProcess[0.1, 1., 0.6], {10, 15, 0.1}, 300];BaringhausHenzeTest[proc1["ValueList"]]The difference of logarithm of geometric Brownian motion:
proc2 = RandomFunction[GeometricBrownianMotionProcess[0.1, 0.6, 1.], {10, 15, 0.1}, 300];BaringhausHenzeTest[Differences /@ Log[proc2["ValueList"]]]The difference of logarithm of the Cox–Ingersoll–Ross process:
proc3 = RandomFunction[CoxIngersollRossProcess[0.1, 0.6, 0.1, 1.], {10, 15, 0.1}, 300];BaringhausHenzeTest[Differences /@ Log[proc3["ValueList"]]]The weights of patients before and after a treatment study were recorded. A multivariate test of means can be used as a check in discriminating between the control and experimental groups if the data that follows is multivariate normally distributed:
data = ExampleData[{"Statistics", "AnorexiaTreatment"}];ExampleData[{"Statistics", "AnorexiaTreatment"}, "ColumnDescriptions"]groups = data[[All, 1]];Use BaringhausHenzeTest to determine if the three groups of data are multivariate normal:
BaringhausHenzeTest[g1 = Pick[data[[All, 2 ;; ]], groups, "Cont"], "ShortTestConclusion"]BaringhausHenzeTest[g2 = Pick[data[[All, 2 ;; ]], groups, "CBT"], "ShortTestConclusion"]BaringhausHenzeTest[g3 = Pick[data[[All, 2 ;; ]], groups, "FT"], "ShortTestConclusion"]The data in the Cont and FT groups are not rejected by the Baringhaus–Henze test. Use TTest to check whether the means of these two groups are identical:
TTest[{g1, g3}, 0, "TestDataTable"]Test the hypothesis that the data follows a standard uncorrelated binormal distribution:
bhep[rho_Real] := BlockRandom[SeedRandom["example"];BaringhausHenzeTest[RandomVariate[BinormalDistribution[rho], 250], ProductDistribution[{NormalDistribution[], 2}]]]LogPlot[bhep[rho], {rho, -0.5, 0.5}, PlotRange -> {0.001, 1}]Properties & Relations (5)
The Baringhaus–Henze test is affine invariant, provided that the linear transformation applied on the data is nonsingular:
data1 = RandomVariate[NormalDistribution[], {1000, 3}];data2 = AffineTransform[{ToeplitzMatrix[3], RandomReal[1, 3]}][data1];Grid[Join[{{"BaringhausHenze Test", "statistic", "p-value"}}, MapThread[Prepend, {{BaringhausHenzeTest[data1, "TestData"], BaringhausHenzeTest[data2, "TestData"]}, {"data1", "data2"}}]], Frame -> All]The Mardia combined test for normality also shares the same property:
Grid[Join[{{"Mardia Combined Test", "statistic", "p-value"}}, MapThread[Prepend, {{MardiaKurtosisTest[data1, "TestData"], MardiaKurtosisTest[data2, "TestData"]}, {"data1", "data2"}}]], Frame -> All]Under
the test statistic asymptotically follows a LogNormalDistribution:
SeedRandom[10];
n = 25;
t = Table[BaringhausHenzeTest[RandomVariate[
MultinormalDistribution[{0, 1}, ToeplitzMatrix[{2, 1}]], n], "TestStatistic"], {10 ^ 3}];Test whether the test statistic follows a distribution from the LogNormalDistribution family:
DistributionFitTest[t, LogNormalDistribution[mu, sig], "ShortTestConclusion"]Show the histogram of the test statistic with the fitted lognormal density:
pdf = PDF[EstimatedDistribution[t, LogNormalDistribution[mu, sig]]]Show[Histogram[t, {0.05}, "PDF"], Plot[pdf[x], {x, 0, 2}]]The BaringhausHenzeTest statistic is based on a distance between the sample empirical characteristic function and the characteristic function under the null hypothesis:
data = RandomVariate[NormalDistribution[], {100, 2}];StandardizeAndDecorrelate[data_] := With[{c = Transpose[Subtract[Transpose[data], Mean[data]]]},
c.Inverse[CholeskyDecomposition[Mean[Outer[Times, #, #]& /@ c]]]]Define the empirical characteristic function and compute the distance:
cf[{t1_, t2_}] = CharacteristicFunction[EmpiricalDistribution[StandardizeAndDecorrelate[data]], {t1, t2}];d[{t1_Real, t2_Real}] := Length[data]Abs[cf[{t1, t2}] - Exp[-(t1 ^ 2 + t2 ^ 2) / 2]] ^ 2NExpectation[d[{t1, t2}], {t1NormalDistribution[0, 2], t2NormalDistribution[0, 2]}]Compare to the value of the test statistic reported by BaringhausHenzeTest:
BaringhausHenzeTest[data, "TestStatistic", Method -> {Automatic, "SmoothingParameter" -> 2}]For samples with degenerate sample covariance function, the test statistic gives its maximum value of 4 n:
htd = BaringhausHenzeTest[ConstantArray[0, {3, 2}], "HypothesisTestData"];htd["TestStatistic"]The corresponding
-value equals zero:
htd["PValue"]For small values of the smoothing parameter β, the Baringhaus–Henze test is more sensitive to the tail behavior:
data = RandomVariate[MultivariateTDistribution[IdentityMatrix[3], 4], {2000, 50}];bhepP[beta_Real] := BaringhausHenzeTest[#, Method -> {Automatic, "SmoothingParameter" -> beta}]& /@ dataThe fraction of rejections of the multivariate normality hypothesis as a function of the smoothing parameter:
Table[{beta, NProbability[x < 0.05, xbhepP[beta]]}, {beta, {0.05, 0.1, 0.5, 1.0, 5.0}}]Table[NProbability[x < 0.05, xtest /@ data], {test, {MardiaCombinedTest, MardiaSkewnessTest, MardiaKurtosisTest}}]Neat Examples (1)
Define a bivariate distribution with standard normal marginals:
bv𝒟 = TransformedDistribution[{X, (2Z - 1) X}, {XNormalDistribution[], ZBernoulliDistribution[2 / 3]}];Marginal distributions are standard Gaussians:
CharacteristicFunction[MarginalDistribution[bv𝒟, 1], t] == CharacteristicFunction[MarginalDistribution[bv𝒟, 2], t] == CharacteristicFunction[NormalDistribution[], t]Sample from the bivariate distribution:
data = RandomVariate[bv𝒟, 1000];Plot the histograms of its components and compare them with the density function of standard normal:
GraphicsRow[Show[Histogram[#, {0.2}, "PDF"], Plot[PDF[NormalDistribution[], x], {x, -3, 3}]]& /@ Transpose[data], ImageSize -> 400]The distribution
is not jointly Gaussian:
BaringhausHenzeTest[data]Show the sampled random vectors on the plane:
ListPlot[data, AspectRatio -> 1, AxesLabel -> {"SubscriptBox[X, 1]", "SubscriptBox[X, 2]"}]Related Guides
History
Text
Wolfram Research (2015), BaringhausHenzeTest, Wolfram Language function, https://reference.wolfram.com/language/ref/BaringhausHenzeTest.html.
CMS
Wolfram Language. 2015. "BaringhausHenzeTest." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/BaringhausHenzeTest.html.
APA
Wolfram Language. (2015). BaringhausHenzeTest. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/BaringhausHenzeTest.html
BibTeX
@misc{reference.wolfram_2026_baringhaushenzetest, author="Wolfram Research", title="{BaringhausHenzeTest}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/BaringhausHenzeTest.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_baringhaushenzetest, organization={Wolfram Research}, title={BaringhausHenzeTest}, year={2015}, url={https://reference.wolfram.com/language/ref/BaringhausHenzeTest.html}, note=[Accessed: 13-June-2026]}