Skip to content

Multivariate normality and its seven tests

See why normal margins don't guarantee joint normality, read a chi-square Q–Q plot of Mahalanobis distances, and use the seven tests as a battery rather than a gate.

Advanced ~12 min9 steps

What runs in CodeSplash

You will be able to

  • Explain why checking each variable alone can't establish multivariate normality
  • Read a chi-square Q–Q plot of squared Mahalanobis distances
  • Say what Mardia, Henze–Zirkler, Henze–Wagner, Royston, Doornik–Hansen and energy tests each look at

Read first

01

Normal margins aren't enough

Predict

Predict first

Two variables each pass a normality check with flying colors. Does that mean that together they follow a bivariate normal distribution?

Yes: normal margins imply joint normalityNo: the dependence between them can be anythingOnly if their correlation is zero
Reveal

No. Normal margins can be joined in many ways. Points may cluster along an X shape or sit in only two quadrants while each margin stays perfectly normal. Multivariate normalityMultivariate normalityAll linear combinations of the variables are normal; normal margins are necessary but not enough. is a claim about the joint shape.

02

One picture to start with

Read

If pp variables are jointly normal, each row's squared Mahalanobis distanceMahalanobis distanceDistance between points or means measured in standard deviations, allowing for the variables' correlations. from the mean follows roughly a χp2\chi^2_p distribution. So you can sort those distances and plot them against χ2\chi^2 quantiles.

Points near the line are compatible with joint normality. A bend at the top means heavy tails or outliers. This chart comes with every test below.

χ² Q–Q plot of Mahalanobis distancesAre the rows (or residuals) multivariate normal, and which rows are multivariate outliers?
View data
D² of each row
3.559
3.043
3.076
3.096
2.791
6.415
1.440
3.980
0.1830
2.001
2.430
1.926
0.0910
0.7760
0.2440
1.331
3.221
0.2280
2.741
8.952
5.344
0.0940
0.4960
1.166
0.3460
3.719
6.055
1.663
7.387
2.144
0.1570
2.421
7.382
3.537
0.5920
0.4200
1.828
3.673
1.752
0.3460
1.852
0.0730
5.904
0.3830
1.547
1.995
3.754
0.7250
2.254
3.263
0.3730
1.954
0.7010
2.586
2.984
3.759
4.140
4.913
0.8240
10.375

First 60 of 120 rows.

03

Seven tests, different lenses

Reflect
TestWhat it looks at
Mardia skewness, kurtosisThird and fourth joint moments, one test each
Henze–ZirklerHenze–Zirkler testCompares the data's characteristic function with the normal one; consistent against any non-normal alternative.Distance between the data's characteristic function and the normal one
Henze–WagnerThe same statistic with a different bandwidth
RoystonShapiro–Wilk per variable, combined allowing for correlation
Doornik–HansenSkewness and kurtosis after transforming toward independence
EnergyEnergy distance from a normal sample

No test beats the others on every shape. Which of these can see a bend that only appears in a combination of variables?

04

Read a battery

In the app

Forty rows of simulated standard-normal data, three variables:

Multivariate normality testsRecorded · Python and R agreeRecorded 2026-11-17 · 23 values compared
R

Henze–Zirkler, HZ = 0.65, p = .424

HZ
0.6532
p
.424
Tests rejecting
0

Plots

χ² Q–Q plot of squared Mahalanobis distancesAre the rows (or residuals) multivariate normal, and which rows are multivariate outliers?
View data
Squared Mahalanobis distance
1.658
2.969
1.761
2.295
1.541
7.210
1.073
1.608
2.088
4.951
3.613
2.766
1.019
1.082
10.271
2.052
1.708
0.8458
1.487
1.712
1.608
0.2861
2.114
3.023
5.855
4.546
5.481
3.421
1.491
4.760
2.642
1.089
3.234
1.379
1.100
1.862
9.210
1.986
5.598
2.608

Assumptions

  • Independent rows — The tests assume independent, identically distributed rows; clustered or time-ordered rows inflate rejections.

Multivariate normality tests

TestStatisticValuedfpReject at α = 0.05
Mardia skewnessχ²7.12810.713no
Mardia kurtosisz−0.4881—.625no
Henze–ZirklerHZ0.6532—.424no
Henze–WagnerHW0.4066—.610no
RoystonH4.9322.993.176no
Doornik–HansenE9.1606.165no
EnergyE0.8039—.550no
  • p-values: asymptotic (χ², normal or lognormal); the energy test always uses 199 Monte-Carlo samples (seed 42).
  • The tests probe different departures (skewness, tails, any shape); a few rejecting is common with real data and large n.
The exact R script · R R version 4.5.1 (2025-06-13)
# Multivariate normality tests
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method multivariate.normality 1.0.2 · spec 9ecdfc634024bc2c
# Dataset: mv_guide_one (version 1)
# Runs on its own: outside the app, cs_publish() writes $CS_RESULT_PATH or prints the result JSON.

# %% Setup
library(codesplashr)

# %% Data
df <- as.data.frame(nanoparquet::read_parquet("tests/parity/fixtures/mv_guide_one.parquet", col_select = c("y1", "y2", "y3")))
n_input <- nrow(df)
df <- df[stats::complete.cases(df[c("y1", "y2", "y3")]), , drop = FALSE]  # listwise deletion
df[] <- lapply(df, function(x) if (is.factor(x)) droplevels(x) else x)
n_dropped <- n_input - nrow(df)
warnings <- list()
if (n_dropped > 0) {
  warnings <- c(warnings, cs_warning("CS_W_ROWS_DROPPED", dropped = n_dropped, total = n_input))
}
if (n_input > 0 && nrow(df) == 0) cs_error("CS_E_NO_ROWS")
cs_check_finite_columns(df, c("y1", "y2", "y3"))  # infinite values stop the run (registry/errors.yaml)

# %% Test
# Multivariate normality (guide 161-167): Mardia skewness and kurtosis, Henze-Zirkler, Henze-Wagner,
# Royston, Doornik-Hansen and the energy test, on the rows or - with groups - on within-group residuals.
variables <- c("y1", "y2", "y3")
test <- "all"  # all or one test
calibration <- "asymptotic"  # asymptotic | bootstrap
n_sim <- as.integer(199)
alpha <- 0.05
seed <- 42
X <- as.matrix(df[variables])
storage.mode(X) <- "double"
# the covariance matrix and its tests need more rows than variables + 1
if (nrow(X) <= length(variables) + 1) cs_error("CS_E_TOO_FEW_ROWS", what = "A multivariate normality test", min = length(variables) + 2, n = nrow(X))
for (j in seq_along(variables)) {
  # a constant variable makes the covariance matrix singular
  if (length(unique(X[, j])) < 2) cs_error("CS_E_CONSTANT", column = variables[j])
}
where <- paste(variables, collapse = ", ")
n <- nrow(X)
dims <- ncol(X)
tests <- if (test == "all") c("mardia_skewness", "mardia_kurtosis", "henze_zirkler", "henze_wagner", "royston", "doornik_hansen", "energy") else test
if ("royston" %in% tests && !(n >= 4 && n <= 2000)) {
  if (test == "royston") stop(sprintf("Royston's test is defined for 4 to 2000 rows; this sample has %d", n))
  tests <- setdiff(tests, "royston")
}
rows <- cs_mvd_normality(X, tests, calibration, n_sim, seed)
names(rows) <- vapply(rows, `[[`, "", "test")
lead <- if (test == "all") rows[["henze_zirkler"]] else rows[[test]]
p <- lead$p
rejects <- Filter(function(r) r$p < alpha, rows)

# %% Assumptions
assumptions <- list(list(key = "independence", label = "Independent rows", status = "info",
  detail = "The tests assume independent, identically distributed rows; clustered or time-ordered rows inflate rejections."))
if (n < 20 && test %in% c("all", "mardia_skewness")) {
  assumptions[[2]] <- list(key = "small_n", label = "Small sample", status = "info",
    detail = sprintf("n = %d < 20: Mardia's skewness uses the small-sample correction; asymptotic p-values are rough — consider the bootstrap.", n))
}

# %% Result
reject_names <- paste(vapply(rejects, `[[`, "", "label"), collapse = ", ")
if (test == "all") {
  hz <- rows[["henze_zirkler"]]
  summary <- paste0(sprintf("%d of %d multivariate normality tests reject at α = %s for %s", length(rejects), length(rows), format(alpha), where),
                    if (length(rejects)) sprintf(" (%s).", reject_names) else ".",
                    sprintf(" Henze–Zirkler: HZ = %.3f, %s.", hz$statistic, cs_fmt_p(hz$p)))
} else {
  summary <- paste0(sprintf("%s test for %s: %s = %.3f, %s — ", lead$label, where, lead$symbol, lead$statistic, cs_fmt_p(p)),
                    if (p < alpha) "evidence against multivariate normality." else "no evidence against multivariate normality.")
}
if (n > 500 && length(rejects)) summary <- paste(summary, "With this many rows trivial departures reject; judge the Q–Q plot as much as the p-values.")
values <- list(test = test, statistic = lead$statistic, p = p, n_reject = length(rejects), n_tests = length(rows), n = n, dims = dims,
               calibration = calibration)
for (r in rows) {
  values[[sprintf("statistic[%s]", r$test)]] <- r$statistic
  values[[sprintf("p[%s]", r$test)]] <- r$p
}
values$missing_share <- if (n_input > 0) n_dropped / n_input else 0
S <- stats::cov(X)
R <- sweep(X, 2, colMeans(X))
d2 <- rowSums((R %*% solve(S)) * R)
cs_publish(list(
  method = "multivariate.normality",
  methodVersion = "1.0.2",
  title = "Multivariate normality tests",
  engine = cs_engine_info("stats", "nanoparquet"),
  n = n,
  summary = summary,
  apa = paste0(sprintf("%s, %s = %s", lead$label, lead$symbol, cs_fmt_num(lead$statistic)),
               if (!is.null(lead$df)) sprintf(" (df = %.2f)", lead$df) else "", sprintf(", %s", cs_fmt_p(p))),
  statistics = list(list(key = "statistic", label = lead$symbol, value = lead$statistic),
                    list(key = "p", label = "p", value = p, format = "p"),
                    list(key = "n_reject", label = "Tests rejecting", value = length(rejects))),
  tables = list(list(key = "tests", title = "Multivariate normality tests",
    columns = list(list(key = "label", label = "Test", type = "string"), list(key = "symbol", label = "Statistic", type = "string"),
                   list(key = "statistic", label = "Value", type = "number"), list(key = "df", label = "df", type = "number"),
                   list(key = "p", label = "p", type = "pvalue"), list(key = "reject", label = sprintf("Reject at α = %s", format(alpha)), type = "string")),
    rows = unname(lapply(rows, function(r) list(label = r$label, symbol = r$symbol, statistic = r$statistic, df = r$df, p = r$p,
                                                reject = if (r$p < alpha) "yes" else "no"))))),
  effectSizes = list(),
  assumptions = assumptions,
  warnings = warnings,
  notes = list(paste0("p-values: ", if (calibration == "bootstrap") "parametric bootstrap from the fitted normal" else "asymptotic (χ², normal or lognormal)",
                      sprintf("; the energy test always uses %d Monte-Carlo samples (seed %d).", n_sim, as.integer(seed))),
               "The tests probe different departures (skewness, tails, any shape); a few rejecting is common with real data and large n."),
  values = values,
  charts = list(cs_chart("qq", "mahalanobis-qq", "χ² Q–Q plot of squared Mahalanobis distances", list(
    d2 = cs_col("Squared Mahalanobis distance", d2)), controls = list(df = dims, envelope = TRUE)))
))
Python

Henze–Zirkler, HZ = 0.65, p = .424

HZ
0.6532
p
.424
Tests rejecting
0

To keep this page light, the plots are shown once, under the R tab.

Assumptions

  • Independent rows — The tests assume independent, identically distributed rows; clustered or time-ordered rows inflate rejections.

Multivariate normality tests

TestStatisticValuedfpReject at α = 0.05
Mardia skewnessχ²7.12810.713no
Mardia kurtosisz−0.4881—.625no
Henze–ZirklerHZ0.6532—.424no
Henze–WagnerHW0.4066—.610no
RoystonH4.9322.993.176no
Doornik–HansenE9.1606.165no
EnergyE0.8039—.550no
  • p-values: asymptotic (χ², normal or lognormal); the energy test always uses 199 Monte-Carlo samples (seed 42).
  • The tests probe different departures (skewness, tails, any shape); a few rejecting is common with real data and large n.
The exact Python script · Python Python 3.13.5 · scipy 1.18.1 · pandas 3.1.0
# Multivariate normality tests
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method multivariate.normality 1.0.2 · spec 9ecdfc634024bc2c
# Dataset: mv_guide_one (version 1)
# Runs on its own: outside the app, cs.publish() writes $CS_RESULT_PATH or prints the result JSON.

# %% Setup
import numpy as np
import pandas as pd

import codesplash as cs
from codesplash.stats import mvdist

# %% Data
df = pd.read_parquet("tests/parity/fixtures/mv_guide_one.parquet", columns=["y1", "y2", "y3"])
n_input = len(df)
df = df.dropna(subset=["y1", "y2", "y3"])  # listwise deletion over the analysis columns
n_dropped = n_input - len(df)
warnings = []
if n_dropped:
    warnings.append(cs.cs_warning("CS_W_ROWS_DROPPED", dropped=n_dropped, total=n_input))
if n_input and not len(df):
    cs.cs_error("CS_E_NO_ROWS")
cs.check_finite_columns(df, ["y1", "y2", "y3"])  # infinite values stop the run (registry/errors.yaml)

# %% Test
# Multivariate normality (guide 161–167): Mardia skewness and kurtosis, Henze–Zirkler, Henze–Wagner,
# Royston, Doornik–Hansen and the energy test, on the rows or — with groups — on within-group residuals.
variables = ["y1", "y2", "y3"]
test = "all"  # all or one test
calibration = "asymptotic"  # asymptotic | bootstrap
n_sim = int(199)
alpha = 0.05
seed = 42
X = df[variables].to_numpy(dtype=float)
if len(X) <= len(variables) + 1:  # the covariance matrix and its tests need more rows than variables + 1
    cs.cs_error("CS_E_TOO_FEW_ROWS", what="A multivariate normality test", min=len(variables) + 2, n=len(X))
for j, v in enumerate(variables):
    if len(np.unique(X[:, j])) < 2:  # a constant variable makes the covariance matrix singular
        cs.cs_error("CS_E_CONSTANT", column=v)
where = ", ".join(variables)
n, dims = X.shape
tests = list(mvdist.NORMALITY_TESTS) if test == "all" else [test]
if "royston" in tests and not 4 <= n <= 2000:
    if test == "royston":
        raise ValueError(f"Royston's test is defined for 4 to 2000 rows; this sample has {n}")
    tests.remove("royston")
rows = mvdist.normality(X, tests, calibration, n_sim, seed)
by = {r["test"]: r for r in rows}
lead = by["henze_zirkler"] if test == "all" else by[test]
p = lead["p"]
rejects = [r for r in rows if r["p"] < alpha]

# %% Assumptions
assumptions = [
    {"key": "independence", "label": "Independent rows", "status": "info",
     "detail": "The tests assume independent, identically distributed rows; clustered or time-ordered rows inflate rejections."},
]
if n < 20 and test in ("all", "mardia_skewness"):
    assumptions.append({"key": "small_n", "label": "Small sample", "status": "info",
                        "detail": f"n = {n} < 20: Mardia's skewness uses the small-sample correction; asymptotic p-values are rough — consider the bootstrap."})

# %% Result
names = ", ".join(r["label"] for r in rejects)
if test == "all":
    summary = (f"{len(rejects)} of {len(rows)} multivariate normality tests reject at α = {alpha:g} for {where}"
               + (f" ({names})." if rejects else ".")
               + f" Henze–Zirkler: HZ = {by['henze_zirkler']['statistic']:.3f}, {cs.fmt_p(by['henze_zirkler']['p'])}.")
else:
    summary = (f"{lead['label']} test for {where}: {lead['symbol']} = {lead['statistic']:.3f}, {cs.fmt_p(p)} — "
               + ("evidence against multivariate normality." if p < alpha else "no evidence against multivariate normality."))
if n > 500 and rejects:
    summary += " With this many rows trivial departures reject; judge the Q–Q plot as much as the p-values."
values = {"test": test, "statistic": lead["statistic"], "p": p, "n_reject": len(rejects), "n_tests": len(rows), "n": n, "dims": dims,
          "calibration": calibration}
for r in rows:
    values[f"statistic[{r['test']}]"] = r["statistic"]
    values[f"p[{r['test']}]"] = r["p"]
values["missing_share"] = n_dropped / n_input if n_input else 0.0
S = np.cov(X, rowvar=False)
R = X - X.mean(axis=0)
d2 = np.einsum("ij,ij->i", R @ np.linalg.inv(S), R)
cs.publish({
    "method": "multivariate.normality",
    "methodVersion": "1.0.2",
    "title": "Multivariate normality tests",
    "engine": cs.engine_info("pandas", "numpy", "scipy"),
    "n": n,
    "summary": summary,
    "apa": (f"{lead['label']}, {lead['symbol']} = {cs.fmt_num(lead['statistic'])}"
            + (f" (df = {lead['df']:.2f})" if lead["df"] is not None else "") + f", {cs.fmt_p(p)}"),
    "statistics": [{"key": "statistic", "label": lead["symbol"], "value": lead["statistic"]},
                   {"key": "p", "label": "p", "value": p, "format": "p"},
                   {"key": "n_reject", "label": "Tests rejecting", "value": len(rejects)}],
    "tables": [{"key": "tests", "title": "Multivariate normality tests",
                "columns": [{"key": "label", "label": "Test", "type": "string"}, {"key": "symbol", "label": "Statistic", "type": "string"},
                            {"key": "statistic", "label": "Value", "type": "number"}, {"key": "df", "label": "df", "type": "number"},
                            {"key": "p", "label": "p", "type": "pvalue"}, {"key": "reject", "label": f"Reject at α = {alpha:g}", "type": "string"}],
                "rows": [{"label": r["label"], "symbol": r["symbol"], "statistic": r["statistic"], "df": r["df"], "p": r["p"],
                          "reject": "yes" if r["p"] < alpha else "no"} for r in rows]}],
    "effectSizes": [],
    "assumptions": assumptions,
    "warnings": warnings,
    "notes": [("p-values: " + ("parametric bootstrap from the fitted normal" if calibration == "bootstrap" else "asymptotic (χ², normal or lognormal)")
               + f"; the energy test always uses {n_sim} Monte-Carlo samples (seed {seed})."),
              "The tests probe different departures (skewness, tails, any shape); a few rejecting is common with real data and large n."],
    "values": values,
    "charts": [cs.chart("qq", "mahalanobis-qq", "χ² Q–Q plot of squared Mahalanobis distances", {
        "d2": cs.col("Squared Mahalanobis distance", d2)}, controls={"df": dims, "envelope": True})],
})

0 of 7 tests reject. Open Multivariate normality tests and check that the p-values vary a lot, even on data that really are normal.

Now a skewed sample with 80 rows. Here 7 of 7 reject, with Henze–Zirkler at p < .001.

05

How the p-values are made

Read

Two options matter here.

Groups: with a group chosen, the tests run on rows centered within each group, since MANOVA's assumption is about residuals. On a skewed sample, Royston's test without groups gives p < .001.

p-values: asymptotic p-values can be poor in small samples, so you can switch to a parametric bootstrap. For three iris variables within species, Doornik–Hansen gives 7.73 with a bootstrap p of 0.23.

The energy test always simulates its p-value, which then has a floor set by the number of simulations.

06

Is this a gate?

Predict

Predict first

You have 3,000 rows and Henze–Zirkler gives p < 0.001 before a MANOVA. What do you do first?

Switch to a nonparametric methodCheck the Q–Q plot and how much your method caresRemove rows until it passes
Reveal

Look first. With thousands of rows, tests reject tiny departures that MANOVA tolerates. If the plot shows a mild bend, Pillai's trace may be fine. If it shows outliers, deal with them. Removing rows until a test passes isn't a remedy. For small samples, the tests have too little power to reassure you.

07

Check your understanding

Checkpoint

Check yourself

You plot squared Mahalanobis distances from three variables. Against a chi-square distribution with how many degrees of freedom?

Show the answer

Answer: 3

One per variable: χ32\chi^2_3. Sample means and covariances make this an approximation, a good one when nn is large compared with pp.

Check yourself

Each variable passes Shapiro–Wilk. Which statement is right?

Show the answer

Answer: b

Joint normality implies normal margins, but not the other way round.

Check yourself

Royston rejects and Henze–Zirkler doesn't. How should you read that?

Show the answer

Answer: c

Each test has its own lens, and their disagreement is information. Decide in advance which you'll report, or report the battery.

08

Do it in CodeSplash

In the app

Choose Variables and optionally Groups. Test defaults to All seven.

Python
import pandas as pd
import pingouin as pg

df = pd.read_csv("scores.csv")
print(pg.multivariate_normality(df[["y1", "y2", "y3"]]))  # Henze-Zirkler
R
# install.packages(c("MVN", "energy"))
df <- read.csv("scores.csv")
MVN::mvn(df[c("y1", "y2", "y3")], mvn_test = "hz")
energy::mvnorm.etest(df[c("y1", "y2", "y3")], R = 999)
09

Recap

Recap
  • Joint normality is more than normal margins.
  • Start with the chi-square Q–Q plot of Mahalanobis distances.
  • The seven tests look at different things, so read them as a battery.
  • Use them as a prompt to look, not as a gate: large samples reject tiny departures, small samples miss large ones.

Concepts in this lesson