BCompare groups · Guide test 163
Henze–Zirkler test
Tests multivariate normality through a weighted empirical characteristic function discrepancy.
Do it in CodeSplash
In the app, set it up in Analyze with this method:
- Multivariate normality tests — Do several variables jointly follow a multivariate normal distribution?
In Multivariate normality tests, choose Test = Henze–Zirkler.
Do it in CodeSplash Run this test on your own data, in Python or R.
Bench
Change the design, drag the data, move α. The statistic, its reference distribution and the verdict follow.
Bench · Henze–Zirkler test
0 is symmetric.
Below 1: heavier tails than normal.
Your data
Simulated with a known ρIf H₀ were true
- The reference: how z varies across samples when H₀ is true (lognormal approximation).
- Your statistic, from the data above.
- The p-value: the area at least as extreme as yours (p = < .001).
- The hatched rejection region at α = .050: statistics landing here reject H₀.
The formula
With your numbers
- Mahalanobis cross-products of the centered rows
- smoothing parameter of the weight function
- approximately normal under H₀: the reference is that lognormal
The verdict
HZ = 1.53, z = 3.21, p < .001
p ≤ α = .050: reject H₀
An affine-invariant distance between the empirical and the normal characteristic function. It detects departures in any direction but says nothing about which.
- Statistic
- 3.208
- p-value
- 0.0007
Henze–Zirkler test on 40 (x, y) pairs: HZ = 1.53, z = 3.21, p < .001. The p-value is below α = .050, so the data are hard to reconcile with H₀.
Question and hypotheses
H0: multivariate normality.
Assumptions
Independent identically distributed p-dimensional observations; positive definite covariance and sufficient n relative to p. The null is a multivariate normal distribution with unknown mean/covariance.
Formula
Parameters and notation
di²=(xi−x̄)ᵀSn⁻¹(xi−x̄); dij²=(xi−xj)ᵀSn⁻¹(xi−xj). The common HZ bandwidth is b=2⁻¹ᐟ²[n(2p+1)/4]^(1/(p+4)).
Structure of the method
Whiten observations and compute both pairwise standardized distances and distances from the fitted center. Gaussian-kernel sums evaluate the weighted empirical-characteristic-function discrepancy without numerically integrating over all frequencies. The HZ smoothing rule connects the kernel scale to sample size and dimension.
Estimated and nuisance parameters
The normal location and covariance are estimated nuisance quantities. The empirical characteristic function and resulting discrepancy are data summaries; the bandwidth is a test-design parameter, even when a published deterministic formula sets it from n and p.
Settings and design choices
Record the exact bandwidth, covariance divisor, numerical inversion tolerance, and lognormal approximation or bootstrap procedure. Trying several bandwidths and reporting only the smallest p-value changes the test and requires multiplicity or joint calibration.
Fitting and adaptation
For a composite-normal null simulation, refit location/covariance and apply the same bandwidth rule to each simulated dataset. Applying the test after a selected nonlinear transformation or learned dimension reduction requires evaluating that full preprocessing pipeline rather than keeping the fitted transformation artificially fixed.
Sensitivity and robustness
Pairwise calculations scale quadratically in n and can be numerically delicate when covariance is nearly singular. Very small or large bandwidths emphasize different departures and may reduce useful power. Standard affine invariance assumes the nonsingular classical setting; pseudoinverse calculations in high dimension do not automatically inherit the same approximation. Inspect outliers, dependence, and effective dimensionality.
How to use and calibrate
Use a matching lognormal approximation or a parametric normal bootstrap that re-estimates location and covariance.
Example application
Assess joint normality beyond marginal skewness and kurtosis.
Interpretation and pitfalls
Watch out
Bandwidth and covariance normalization change the statistic. HZ and HW are overlapping family members, not unrelated evidence.
What changed in edition 2
- New sections: structure of the method, estimated and nuisance parameters, settings and design choices, fitting and adaptation, sensitivity and robustness.
Python and R
Current MVN function interface. Mardia prints skewness and kurtosis components together: use the component named in this entry. Covariance must be estimable and observations independent.
Not run — Python launcher syntax checked; R backend runtime not verified · needs Python standard library + Rscript; R packages: MVN
# Python launcher for the complete R implementation below.
# Requires Rscript on PATH and the listed R packages.
import shutil
import subprocess
rscript = shutil.which("Rscript")
if rscript is None:
raise RuntimeError("Install R and make Rscript available on PATH.")
r_code = r"""
set.seed(2026)
X<-matrix(rnorm(120),ncol=3);Y<-matrix(rnorm(150,mean=.3),ncol=3)
print(MVN::hz(X))
"""
# No shell interpolation. A failed R execution raises an error in Python.
result = subprocess.run([rscript, "--vanilla", "-"], input=r_code,
text=True, capture_output=True)
print(result.stdout)
if result.stderr:
print(result.stderr)
result.check_returncode()
Not run — Syntax checked; runtime not verified in the final environment · needs MVN
set.seed(2026)
X<-matrix(rnorm(120),ncol=3);Y<-matrix(rnorm(150,mean=.3),ncol=3)
print(MVN::hz(X))
Sources
- MVN — MVN · hzAuthor documentation/source reviewed: MVN 6.3.rdrr.io
- hzrdrr.io
- hzsearch.r-project.org
- Statistics guide v4 (historical):
- Python: Python launcher syntax checked; R backend runtime not verified · R: Syntax checked; runtime not verified in the final environment
- Reference's record:
- Edition 2 review: Python: skip · R: not executed (Rscript unavailable); why not run: Python: Python-to-R bridge; Rscript is unavailable. R code was not executed. Python: Not run in the reference's review: Python-to-R bridge; Rscript is unavailable. R code was not executed. R: Reviewed but not run: R wasn't available to the reference's authors.
From the CodeSplash statistics guide (v4), entry 163, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT163.