Skip to content

Normality tests are not verdicts

The eleven normality tests in CodeSplash, what each one looks at, and why a plot and a question about robustness matter more than a p-value.

Applied ~15 min9 steps

What runs in CodeSplash

You will be able to

  • Group normality tests by what they measure
  • Explain why large samples reject trivial departures
  • Combine a Q–Q plot, a test and a question about robustness

Read first

01

What's the question?

Read

A normality test asks: are these data compatible with a normal distribution?

That's rarely what you need. What you usually need is: will my method be misled by this much non-normality, at this sample size? A t test on 200 values barely notices moderate skew. A test can flag it anyway, and on 8 values a test can miss a serious problem.

02

Build a Q–Q plot

Explore

A Q–Q plot compares your sorted values with the values a normal distribution would give. Points on the line are compatible with normality. An S-shape suggests tail problems, and a curve suggests skew.

Change the shape and learn the patterns.

AExplorable · Build a Q–Q plot

How do skewness and heavy tails show up in a normal Q–Q plot?

Before plotting: what pattern will the points make?

How sure?
0.80
1.00

Below 1: heavier tails.

80

Commit your prediction above to see the result

Make your prediction first; the figure appears when you commit.

Make your prediction to see the result.

03

Sample size changes the verdict

Predict

Predict first

A column is slightly non-normal, a departure no method would care about. At which sample size does a normality test reject more often?

At n = 20At n = 5,000Equally often
Reveal

The answer: At n = 5,000

At 5,000. Large samples detect trivial departures, and small samples miss real ones. Try it below: the rejection rate climbs with n, as the shape stays the same.

AExplorable · The normality-test paradox

Why is a normality test least helpful exactly when you might rely on it?

How often does Shapiro–Wilk reject this skew at n = 1,000?

0.50
How sure?
0.05
Simulating…

Commit your prediction above to see the result

Make your prediction first; the figure appears when you commit.

Make your prediction to see the result.

04

The tests, by what they look at

Read
GroupTests
Correlation with normal order statisticsShapiro–Wilk, Shapiro–Francia, Filliben PPCC
Momentsskewness, kurtosis, D'Agostino–Pearson, Jarque–Bera
Distance from the normal CDFLilliefors, Anderson–Darling, Cramér–von Mises
Binned countsPearson χ2\chi^2

Shapiro–Wilk is a strong general default. Anderson–Darling gives more weight to tails. The moment tests tell you which feature departs.

05

Skewed ozone

In the app

Ozone is the obvious suspect. All 116 readings go through the battery, and every test rejects.

Shapiro–Francia gives W′=W' = 0.879, p < .001. D'Agostino–Pearson gives K2=K^2 = 26.5, and Jarque–Bera gives 35.8.

The skewness test has z=z = 4.66, and the kurtosis test has z=z = 2.20. So skew is the main story.

New York air quality, 1973
06

Not every sample fails

In the app

The battery on three small PlantGrowth groups gives one verdict for each:

Normality testsRecorded · Python and R agreeRecorded 2026-11-17 · 100 values compared
R

0 of 3 groups of weight depart from normality by the n-dependent rule.

Tests rejecting
0
Tests run
11
Departing
0
Groups
3

Plots

Normal Q–Q: weight (ctrl)Is a variable (or a set of residuals) approximately normal, and where does it depart?
View data
weight
4.170
5.580
5.180
6.110
4.500
4.610
5.170
4.530
5.330
5.140
Normal Q–Q: weight (trt1)Is a variable (or a set of residuals) approximately normal, and where does it depart?
View data
weight
4.810
4.170
4.410
3.590
5.870
3.830
6.030
4.890
4.320
4.690
Normal Q–Q: weight (trt2)Is a variable (or a set of residuals) approximately normal, and where does it depart?
View data
weight
6.310
5.120
5.540
5.500
5.370
5.290
4.920
6.150
5.800
5.260

Normality tests

groupTestStatisticpRejects at .05
ctrlShapiro–Wilk0.9567.747no
ctrlShapiro–Francia0.9553.694no
ctrlFilliben probability-plot correlation0.9771.657no
ctrlAnderson–Darling0.2829.555no
ctrlLilliefors (Kolmogorov–Smirnov)0.1735.528no
ctrlCramér–von Mises0.0495.482no
ctrlD'Agostino–Pearson omnibus0.2335.890no
ctrlJarque–Bera0.3120.856no
ctrlD'Agostino skewness0.4831.629no
ctrlAnscombe–Glynn kurtosis0.0104.992no
ctrlPearson χ²4.400.221no
trt1Shapiro–Wilk0.9304.452no
trt1Shapiro–Francia0.9380.474no
trt1Filliben probability-plot correlation0.9687.473no
trt1Anderson–Darling0.3298.444no
trt1Lilliefors (Kolmogorov–Smirnov)0.1865.410no
trt1Cramér–von Mises0.0490.491no
trt1D'Agostino–Pearson omnibus0.9677.616no
trt1Jarque–Bera0.6962.706no
trt1D'Agostino skewness0.9832.326no
trt1Anscombe–Glynn kurtosis0.0329.974no
trt1Pearson χ²3.200.362no
trt2Shapiro–Wilk0.9410.564no
trt2Shapiro–Francia0.9467.578no
trt2Filliben probability-plot correlation0.9730.563no
trt2Anderson–Darling0.3089.503no
trt2Lilliefors (Kolmogorov–Smirnov)0.1874.403no
trt2Cramér–von Mises0.0513.456no
trt2D'Agostino–Pearson omnibus1.013.603no
trt2Jarque–Bera0.7585.684no
trt2D'Agostino skewness1.004.315no
trt2Anscombe–Glynn kurtosis−0.0725.942no
trt2Pearson χ²2.572no

Shape and verdict

groupnTests rejectingSkewness (G1)zExcess kurtosis (G2)zVerdict
ctrl1000.32100.4672−0.2291−0.1717no evidence against normality
trt11000.65900.9591−0.2028−0.1520no evidence against normality
trt21000.67320.9799−0.3242−0.2430no evidence against normality
  • Verdict: n < 50 → Shapiro–Wilk at α = .05; 50–299 → |z| of skewness or kurtosis > 3.29; n ≥ 300 → |G1| > 2 or excess kurtosis > 4 (Kim 2013). With large samples every test rejects trivial departures, so the magnitudes decide.
  • All eleven tests estimate the mean and SD (composite null). Shapiro–Wilk needs 3–5,000 values, Shapiro–Francia 5–5,000, Anderson–Darling, Cramér–von Mises, Pearson χ² and the D'Agostino tests at least 8, Lilliefors at least 5.
  • Filliben's p compares r with 1999 normal samples of the same size (seed 42); the tests overlap, so 'k of 11 reject' is a summary of agreement, not a combined test.
The exact R script · R R version 4.5.1 (2025-06-13)
# Normality tests (battery)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method normality.battery 1.1.1 · spec 443cb27941ed89ce
# Dataset: plantgrowth (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/plantgrowth.parquet", col_select = c("weight", "group")))
n_input <- nrow(df)
df[["group"]] <- factor(df[["group"]], levels = c("ctrl", "trt1", "trt2"))  # stored level order
df <- df[stats::complete.cases(df[c("weight", "group")]), , 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("weight", "group"))  # infinite values stop the run (registry/errors.yaml)

# %% Tests
y <- "weight"
g <- "group"
parts <- lapply(levels(df[[g]]), function(lv) list(level = lv, x = df[[y]][df[[g]] == lv]))
if (nrow(df) >= 2 && length(unique(df[[y]])) < 2) cs_error("CS_E_CONSTANT", column = y)  # no variation: every test and shape measure is undefined
alpha <- 0.05

verdict <- function(n, sw_p, m, flat = FALSE) {
  # n-dependent rule (Kim 2013): tests for small n, standardized shape for moderate n, magnitudes for large n.
  if (n < 8) return(list(FALSE, "too few values to judge"))
  if (flat) return(list(FALSE, "no variation to judge"))  # every value the same: tests and shape are undefined
  if (n < 50) {
    bad <- is.finite(sw_p) && sw_p < alpha
    return(list(bad, if (bad) "departs from normality (Shapiro–Wilk)" else "no evidence against normality"))
  }
  if (n < 300) {
    bad <- abs(m$skewness_z) > 3.29 || abs(m$kurtosis_z) > 3.29
    return(list(bad, if (bad) "departs from normality (|z| of skewness or kurtosis > 3.29)" else "approximately normal in shape"))
  }
  bad <- abs(m$skewness) > 2 || m$kurtosis > 4
  list(bad, if (bad) "substantially non-normal (|G1| > 2 or G2 > 4)" else "approximately normal in shape (large n: judged by magnitude)")
}

# Each test: c(statistic key, p key) in the published values.
keys <- list(shapiro_wilk = c("sw_w", "sw_p"), shapiro_francia = c("sf_w", "sf_p"), filliben = c("ppcc_r", "ppcc_p"),
             anderson_darling = c("ad_a", "ad_p"), lilliefors = c("lillie_d", "lillie_p"), cramer_von_mises = c("cvm_w2", "cvm_p"),
             dagostino_pearson = c("k2", "k2_p"), jarque_bera = c("jb", "jb_p"), skewness = c("skew_z", "skew_p"),
             kurtosis = c("kurt_z", "kurt_p"), pearson_chisq = c("chisq", "chisq_p"))
seed <- 42  # Filliben's p: normal samples from the shared Wichmann-Hill stream
reps <- as.integer(1999)

rows <- list()
tests <- list()
values <- list(n_total = nrow(df))
for (pt in parts) {
  x <- pt$x[!is.na(pt$x)]
  n <- length(x)
  part <- list(n = n)
  n_tests <- 0
  n_reject <- 0
  for (name in cs_normality_test_names()) {
    r <- cs_normality_test(x, name, seed = seed, reps = reps)
    part[[keys[[name]][1]]] <- r$statistic
    part[[keys[[name]][2]]] <- r$p
    if (name == "pearson_chisq") part$chisq_df <- if (is.null(r$df) || r$df == 0) NaN else r$df
    tested <- is.finite(r$p)
    n_tests <- n_tests + tested
    n_reject <- n_reject + (tested && r$p < alpha)
    tests[[length(tests) + 1]] <- c(if (!is.null(g)) list(group = pt$level),
                                    list(test = r$label, statistic = r$statistic, p = r$p,
                                         reject = if (tested) (if (r$p < alpha) "yes" else "no") else "not computed"))
  }
  m <- cs_moments(x)
  vd <- verdict(n, part$sw_p, m, flat = n > 0 && diff(range(x)) == 0)
  part <- c(part, list(n_tests = n_tests, n_reject = n_reject, skewness = m$skewness, skewness_z = m$skewness_z,
                       kurtosis = m$kurtosis, kurtosis_z = m$kurtosis_z, depart = vd[[1]], verdict = vd[[2]]))
  for (k in names(part)) values[[sprintf("%s[%s]", k, pt$level)]] <- part[[k]]
  rows[[length(rows) + 1]] <- c(if (!is.null(g)) list(group = pt$level), part)
}

# %% Result
departing <- Filter(function(r) isTRUE(r$depart), rows)
values$n_parts <- length(rows)
values$n_departing <- length(departing)
values$lead <- parts[[1]]$level
group_col <- if (!is.null(g)) list(list(key = "group", label = g, type = "string")) else list()
charts <- list()
for (i in seq_len(min(6, length(parts)))) {
  x <- parts[[i]]$x
  if (length(x) < 3) next
  rc <- unique(round(seq(1, length(x), length.out = min(length(x), 5000))))
  charts[[length(charts) + 1]] <- cs_chart(sprintf("qq-%d", i - 1), "qq",
                                           paste0("Normal Q–Q: ", y, if (!is.null(g)) sprintf(" (%s)", parts[[i]]$level) else ""),
                                           list(x = cs_col(y, x[rc])))
}
cs_publish(list(
  method = "normality.battery",
  methodVersion = "1.1.1",
  title = "Normality tests",
  engine = cs_engine_info("stats", "nanoparquet"),
  n = nrow(df),
  summary = paste0(
    if (is.null(g)) sprintf("%d of %d tests reject normality at α = .05 for %s; by the n-dependent rule it %s from normality.",
                            rows[[1]]$n_reject, rows[[1]]$n_tests, y, if (isTRUE(rows[[1]]$depart)) "departs" else "does not depart")
    else sprintf("%d of %d groups of %s depart from normality by the n-dependent rule.", length(departing), length(rows), y),
    if (any(vapply(rows, function(r) r$n >= 300, logical(1)))) " With n ≥ 300 every test rejects trivial departures — read the shape, not the p-values." else ""),
  statistics = list(list(key = "n_reject", label = "Tests rejecting", value = rows[[1]]$n_reject), list(key = "n_tests", label = "Tests run", value = rows[[1]]$n_tests),
                    list(key = "n_departing", label = "Departing", value = length(departing)), list(key = "n_parts", label = "Groups", value = length(rows))),
  tables = list(
    list(key = "tests", title = "Normality tests", columns = c(group_col, list(
      list(key = "test", label = "Test", type = "string"), list(key = "statistic", label = "Statistic", type = "number"),
      list(key = "p", label = "p", type = "pvalue"), list(key = "reject", label = "Rejects at .05", type = "string"))), rows = tests),
    list(key = "shape", title = "Shape and verdict", columns = c(group_col, list(
      list(key = "n", label = "n", type = "integer"), list(key = "n_reject", label = "Tests rejecting", type = "integer"),
      list(key = "skewness", label = "Skewness (G1)", type = "number"),
      list(key = "skewness_z", label = "z", type = "number"), list(key = "kurtosis", label = "Excess kurtosis (G2)", type = "number"),
      list(key = "kurtosis_z", label = "z", type = "number"), list(key = "verdict", label = "Verdict", type = "string"))),
      rows = lapply(rows, function(r) r[intersect(c("group", "n", "n_reject", "skewness", "skewness_z", "kurtosis", "kurtosis_z", "verdict"), names(r))]))
  ),
  effectSizes = list(),
  assumptions = list(),
  warnings = warnings,
  notes = list(
    paste("Verdict: n < 50 → Shapiro–Wilk at α = .05; 50–299 → |z| of skewness or kurtosis > 3.29; n ≥ 300 → |G1| > 2 or excess kurtosis > 4 (Kim 2013).",
          "With large samples every test rejects trivial departures, so the magnitudes decide."),
    paste("All eleven tests estimate the mean and SD (composite null). Shapiro–Wilk needs 3–5,000 values, Shapiro–Francia 5–5,000,",
          "Anderson–Darling, Cramér–von Mises, Pearson χ² and the D'Agostino tests at least 8, Lilliefors at least 5."),
    sprintf("Filliben's p compares r with %d normal samples of the same size (seed %d); the tests overlap, so 'k of 11 reject' is a summary of agreement, not a combined test.", reps, as.integer(seed))
  ),
  charts = charts,
  values = values
))
Python

0 of 3 groups of weight depart from normality by the n-dependent rule.

Tests rejecting
0
Tests run
11
Departing
0
Groups
3

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

Normality tests

groupTestStatisticpRejects at .05
ctrlShapiro–Wilk0.9567.747no
ctrlShapiro–Francia0.9553.694no
ctrlFilliben probability-plot correlation0.9771.657no
ctrlAnderson–Darling0.2829.555no
ctrlLilliefors (Kolmogorov–Smirnov)0.1735.528no
ctrlCramér–von Mises0.0495.482no
ctrlD'Agostino–Pearson omnibus0.2335.890no
ctrlJarque–Bera0.3120.856no
ctrlD'Agostino skewness0.4831.629no
ctrlAnscombe–Glynn kurtosis0.0104.992no
ctrlPearson χ²4.400.221no
trt1Shapiro–Wilk0.9304.452no
trt1Shapiro–Francia0.9380.474no
trt1Filliben probability-plot correlation0.9687.473no
trt1Anderson–Darling0.3298.444no
trt1Lilliefors (Kolmogorov–Smirnov)0.1865.410no
trt1Cramér–von Mises0.0490.491no
trt1D'Agostino–Pearson omnibus0.9677.616no
trt1Jarque–Bera0.6962.706no
trt1D'Agostino skewness0.9832.326no
trt1Anscombe–Glynn kurtosis0.0329.974no
trt1Pearson χ²3.200.362no
trt2Shapiro–Wilk0.9410.564no
trt2Shapiro–Francia0.9467.578no
trt2Filliben probability-plot correlation0.9730.563no
trt2Anderson–Darling0.3089.503no
trt2Lilliefors (Kolmogorov–Smirnov)0.1874.403no
trt2Cramér–von Mises0.0513.456no
trt2D'Agostino–Pearson omnibus1.013.603no
trt2Jarque–Bera0.7585.684no
trt2D'Agostino skewness1.004.315no
trt2Anscombe–Glynn kurtosis−0.0725.942no
trt2Pearson χ²2.000.572no

Shape and verdict

groupnTests rejectingSkewness (G1)zExcess kurtosis (G2)zVerdict
ctrl1000.32100.4672−0.2291−0.1717no evidence against normality
trt11000.65900.9591−0.2028−0.1520no evidence against normality
trt21000.67320.9799−0.3242−0.2430no evidence against normality
  • Verdict: n < 50 → Shapiro–Wilk at α = .05; 50–299 → |z| of skewness or kurtosis > 3.29; n ≥ 300 → |G1| > 2 or excess kurtosis > 4 (Kim 2013). With large samples every test rejects trivial departures, so the magnitudes decide.
  • All eleven tests estimate the mean and SD (composite null). Shapiro–Wilk needs 3–5,000 values, Shapiro–Francia 5–5,000, Anderson–Darling, Cramér–von Mises, Pearson χ² and the D'Agostino tests at least 8, Lilliefors at least 5.
  • Filliben's p compares r with 1999 normal samples of the same size (seed 42); the tests overlap, so 'k of 11 reject' is a summary of agreement, not a combined test.
The exact Python script · Python Python 3.13.5 · scipy 1.18.1 · pandas 3.1.0
# Normality tests (battery)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method normality.battery 1.1.1 · spec 443cb27941ed89ce
# Dataset: plantgrowth (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
from scipy import stats

import codesplash as cs
from codesplash.stats import describe as csd
from codesplash.stats import normality as csn

# %% Data
df = pd.read_parquet("tests/parity/fixtures/plantgrowth.parquet", columns=["weight", "group"])
n_input = len(df)
df["group"] = pd.Categorical(df["group"], categories=["ctrl", "trt1", "trt2"])  # stored level order
df = df.dropna(subset=["weight", "group"])  # listwise deletion over the analysis columns
df["group"] = df["group"].cat.remove_unused_categories()
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, ["weight", "group"])  # infinite values stop the run (registry/errors.yaml)

# %% Tests
y = "weight"
g = "group"
parts = [(str(lv), df.loc[df[g] == lv, y].to_numpy(dtype=float)) for lv in df[g].cat.categories]
if len(df) >= 2 and len(np.unique(df[y].to_numpy(dtype=float))) < 2:  # no variation: every test and shape measure is undefined
    cs.cs_error("CS_E_CONSTANT", column=y)
alpha = 0.05
nan = float("nan")


def verdict(n, sw_p, m, flat=False):
    """n-dependent rule (Kim 2013): tests for small n, standardized shape for moderate n, shape
    magnitudes for large n (where any test rejects trivial departures)."""
    if n < 8:
        return False, "too few values to judge"
    if flat:  # every value the same: the tests and shape measures are undefined
        return False, "no variation to judge"
    if n < 50:
        bad = np.isfinite(sw_p) and sw_p < alpha
        return bool(bad), "departs from normality (Shapiro–Wilk)" if bad else "no evidence against normality"
    if n < 300:
        bad = abs(m["skewness_z"]) > 3.29 or abs(m["kurtosis_z"]) > 3.29
        return bool(bad), "departs from normality (|z| of skewness or kurtosis > 3.29)" if bad else "approximately normal in shape"
    bad = abs(m["skewness"]) > 2 or m["kurtosis"] > 4
    return bool(bad), "substantially non-normal (|G1| > 2 or G2 > 4)" if bad else "approximately normal in shape (large n: judged by magnitude)"


# Each test: (statistic key, p key) in the published values.
KEYS = {"shapiro_wilk": ("sw_w", "sw_p"), "shapiro_francia": ("sf_w", "sf_p"), "filliben": ("ppcc_r", "ppcc_p"),
        "anderson_darling": ("ad_a", "ad_p"), "lilliefors": ("lillie_d", "lillie_p"), "cramer_von_mises": ("cvm_w2", "cvm_p"),
        "dagostino_pearson": ("k2", "k2_p"), "jarque_bera": ("jb", "jb_p"), "skewness": ("skew_z", "skew_p"),
        "kurtosis": ("kurt_z", "kurt_p"), "pearson_chisq": ("chisq", "chisq_p")}
seed, reps = 42, int(1999)  # Filliben's p: normal samples from the shared Wichmann–Hill stream

rows, tests, values = [], [], {"n_total": len(df)}
for level, x in parts:
    x = x[~np.isnan(x)]
    n = x.size
    part = {"n": n}
    n_tests = n_reject = 0
    for name in csn.TESTS:
        r = csn.normality_test(x, name, seed=seed, reps=reps)
        sk, pk = KEYS[name]
        part[sk], part[pk] = r["statistic"], r["p"]
        if name == "pearson_chisq":
            part["chisq_df"] = r["df"] if r["df"] else nan
        tested = np.isfinite(r["p"])
        n_tests += int(tested)
        n_reject += int(tested and r["p"] < alpha)
        tests.append({"group": level, "test": r["label"], "statistic": r["statistic"], "p": r["p"],
                      "reject": ("yes" if r["p"] < alpha else "no") if tested else "not computed"})
    m = csd.moments(x)
    bad, text = verdict(n, part["sw_p"], m, flat=bool(n) and np.ptp(x) == 0)
    part.update({"n_tests": n_tests, "n_reject": n_reject, "skewness": m["skewness"], "skewness_z": m["skewness_z"],
                 "kurtosis": m["kurtosis"], "kurtosis_z": m["kurtosis_z"], "depart": bad, "verdict": text})
    values.update({f"{k}[{level}]": v for k, v in part.items()})
    rows.append({"group": level, **part})

# %% Result
departing = [r for r in rows if r["depart"]]
values.update({"n_parts": len(rows), "n_departing": len(departing), "lead": rows[0]["group"]})
group_col = [{"key": "group", "label": g, "type": "string"}] if g else []
charts = [
    cs.chart(f"qq-{i}", "qq", f"Normal Q–Q: {y}" + (f" ({level})" if g else ""),
             {"x": cs.col(y, x[np.unique(np.round(np.linspace(0, x.size - 1, min(x.size, 5000))).astype(int))])})
    for i, (level, x) in enumerate(parts[:6]) if x.size >= 3
]
cs.publish({
    "method": "normality.battery",
    "methodVersion": "1.1.1",
    "title": "Normality tests",
    "engine": cs.engine_info("pandas", "numpy", "scipy"),
    "n": len(df),
    "summary": (f"{rows[0]['n_reject']} of {rows[0]['n_tests']} tests reject normality at α = .05 for {y}; by the n-dependent rule it {'departs' if rows[0]['depart'] else 'does not depart'} from normality."
                if not g else f"{len(departing)} of {len(rows)} groups of {y} depart from normality by the n-dependent rule.")
               + (" With n ≥ 300 every test rejects trivial departures — read the shape, not the p-values." if any(r["n"] >= 300 for r in rows) else ""),
    "statistics": [{"key": "n_reject", "label": "Tests rejecting", "value": rows[0]["n_reject"]}, {"key": "n_tests", "label": "Tests run", "value": rows[0]["n_tests"]},
                   {"key": "n_departing", "label": "Departing", "value": len(departing)}, {"key": "n_parts", "label": "Groups", "value": len(rows)}],
    "tables": [
        {"key": "tests", "title": "Normality tests", "columns": group_col + [
            {"key": "test", "label": "Test", "type": "string"}, {"key": "statistic", "label": "Statistic", "type": "number"},
            {"key": "p", "label": "p", "type": "pvalue"}, {"key": "reject", "label": "Rejects at .05", "type": "string"}],
         "rows": [{k: v for k, v in t.items() if g or k != "group"} for t in tests]},
        {"key": "shape", "title": "Shape and verdict", "columns": group_col + [
            {"key": "n", "label": "n", "type": "integer"}, {"key": "n_reject", "label": "Tests rejecting", "type": "integer"},
            {"key": "skewness", "label": "Skewness (G1)", "type": "number"},
            {"key": "skewness_z", "label": "z", "type": "number"}, {"key": "kurtosis", "label": "Excess kurtosis (G2)", "type": "number"},
            {"key": "kurtosis_z", "label": "z", "type": "number"}, {"key": "verdict", "label": "Verdict", "type": "string"}],
         "rows": [{k: r[k] for k in ("group", "n", "n_reject", "skewness", "skewness_z", "kurtosis", "kurtosis_z", "verdict") if g or k != "group"} for r in rows]},
    ],
    "effectSizes": [],
    "assumptions": [],
    "warnings": warnings,
    "notes": [
        "Verdict: n < 50 → Shapiro–Wilk at α = .05; 50–299 → |z| of skewness or kurtosis > 3.29; n ≥ 300 → |G1| > 2 or excess kurtosis > 4 (Kim 2013). "
        "With large samples every test rejects trivial departures, so the magnitudes decide.",
        "All eleven tests estimate the mean and SD (composite null). Shapiro–Wilk needs 3–5,000 values, Shapiro–Francia 5–5,000, "
        "Anderson–Darling, Cramér–von Mises, Pearson χ² and the D'Agostino tests at least 8, Lilliefors at least 5.",
        f"Filliben's p compares r with {reps} normal samples of the same size (seed {seed}); the tests overlap, so "
        "'k of 11 reject' is a summary of agreement, not a combined test.",
    ],
    "charts": charts,
    "values": values,
})

MPG in mtcars gives Shapiro–Wilk p = .123, Anderson–Darling p = .121, and Filliben p = .153.

These small samples can't rule out moderate departures, so a large p-value isn't a certificate.

07

What to do with the result

Reflect

Use this order:

  1. Look at the histogram and the Q–Q plot.
  2. Ask whether your method is robust at this sample size. A t test or ANOVA with moderate samples usually is.
  3. Use a test as one clue, especially at small or moderate n.

In Insights (⌘5), a numeric column's page has a Normality panel. Which analysis of yours relied on a test alone?

08

Check your understanding

Checkpoint

Check yourself

With 50,000 rows, Shapiro–Francia gives p < .001, and the Q–Q plot is nearly straight. What do you conclude?

Show the answer

Answer: b

With that much data, tiny departures reach significance. Size matters more than the p-value here.

Check yourself

Which test looks most directly at the tails?

Show the answer

Answer: b

Anderson–Darling weights the tails of the distribution heavily. The skewness test looks at asymmetry, and binning discards detail.

Check yourself

A Q–Q plot's points curve upward at both ends, forming an S. What does that suggest?

Show the answer

Answer: b

Extreme values lie further out than a normal curve predicts at both ends.

Check yourself

Shapiro–Wilk on MPG in mtcars gives what WW? Run normality.shapiro on it, or read the example: give three decimals.

Show the answer

Answer: 0.947564726479274

It's close to 1, as expected for a sample that a test doesn't flag.

Check yourself

A test on 8 values gives p = 0.60. What can you say?

Show the answer

Answer: b

Absence of evidence isn't evidence of absence, and at this size the test can't see much. Look at the plot and think about the process that produced the data.

09

Recap

Recap
  • Normality tests answer a narrower question than the one you have.
  • Large samples flag trivial departures, and small samples miss serious ones.
  • Look, ask about robustness, and use a test as one clue.

Concepts in this lesson