Skip to content

BCompare groups · Guide test 163

Henze–Zirkler test

Tests multivariate normality through a weighted empirical characteristic function discrepancy.

Runs in CodeSplashPython (calls R) example not runR example not run

Do it in CodeSplash

In the app, set it up in Analyze with this method:

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

40
0.50
0.60

0 is symmetric.

1.00

Below 1: heavier tails than normal.

0.050

Your data

Simulated with a known ρ

If H₀ were true

z = 3.21
  1. The reference: how z varies across samples when H₀ is true (lognormal approximation).
  2. Your statistic, from the data above.
  3. The p-value: the area at least as extreme as yours (p = < .001).
  4. The hatched rejection region at α = .050: statistics landing here reject H₀.

The formula

HZ=n[1n2∑i,je−β22Dij−2n(1+β2)p/2∑ie−β22(1+β2)Dii+(1+2β2)−p/2]HZ = n\Bigl[\tfrac{1}{n^2}\sum_{i,j} e^{-\frac{\beta^2}{2}D_{ij}} - \tfrac{2}{n(1+\beta^2)^{p/2}}\sum_i e^{-\frac{\beta^2}{2(1+\beta^2)}D_{ii}} + (1+2\beta^2)^{-p/2}\Bigr]

With your numbers

HZ=1.53,β=1.36,n=40HZ = 1.53,\qquad \beta = 1.36,\qquad n = 40
DijD_{ij}
Mahalanobis cross-products of the centered rows
β\beta
smoothing parameter of the weight function
log⁡HZ\log HZ
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 H0.

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

Tb=n[1n2∑ije−b2dij2/2−2n(1+b2)p/2∑ie−b2di2/[2(1+b2)]+(1+2b2)−p/2]T_b=n\left[\frac1{n^2}\sum_{ij}e^{-b^2d_{ij}^2/2}-\frac{2}{n(1+b^2)^{p/2}}\sum_ie^{-b^2d_i^2/[2(1+b^2)]}+(1+2b^2)^{-p/2}\right]

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.

Python · invokes R

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()
R

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

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.