Skip to content

ADescribe · Guide test 108

Lilliefors normality test

Recalibrates the Kolmogorov–Smirnov statistic when normal mean and variance are estimated from the sample.

Runs in CodeSplashPython example validatedR example validated

Do it in CodeSplash

In the app, set it up in Analyze with one of these methods:

In Normality test (one test), choose Test = Lilliefors (Kolmogorov–Smirnov).

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 · Lilliefors normality test

40
0.60

Sinh–arcsinh shape: 0 is symmetric.

1.00

Below 1: heavier tails than normal; 1 with ε = 0 is exactly normal.

0.050

Your data

Drag a point or use ↑/↓ to change it
Sample · n = 40 · mean 0.63

If H₀ were true

D = 0.14
  1. The reference: how D varies across samples when H₀ is true (Null Atlas: quantiles simulated with 200,000 replicates).
  2. Your statistic, from the data above.
  3. The p-value: the area at least as extreme as yours (p = .046).
  4. The hatched rejection region at α = .050: statistics landing here reject H₀.

The formula

D=max⁡i{in−Φ(z(i)),  Φ(z(i))−i−1n},zi=xi−xˉsD = \max_i\left\{\tfrac{i}{n} - \Phi(z_{(i)}),\; \Phi(z_{(i)}) - \tfrac{i-1}{n}\right\},\qquad z_i = \dfrac{x_i - \bar x}{s}

With your numbers

D=0.14,n=40D = 0.14,\qquad n = 40
z(i)z_{(i)}
the standardized data, sorted
Φ\Phi
the standard normal CDF
DD
the largest gap between the empirical and normal CDFs

The verdict

D = 0.140, p = .046

p ≤ α = .050: reject H₀

Same statistic as Kolmogorov–Smirnov, but estimating the mean and SD pulls the fit closer to the data, so the ordinary KS null is far too generous. No formula gives this null, so the reference here is simulated: the Null Atlas.

Statistic
0.140
p-value
0.0460
Lilliefors normality test on Sample: n = 40: D = 0.140, p = .046. The p-value is below α = .050, so the data are hard to reconcile with H0.

Lilliefors normality test on Sample: n = 40: D = 0.140, p = .046. The p-value is below α = .050, so the data are hard to reconcile with H₀.

Question and hypotheses

H0: normality with mean and variance estimated from the same sample.

Assumptions

Independent identically distributed continuous observations; H0 is a normal distribution with unknown mean and positive variance. Censoring, truncation, clustering and fitted regression residuals require different calibration.

Formula

D=sup⁡x∣Fn(x)−Φ((x−xˉ)/s)∣D=\sup_x|F_n(x)-\Phi((x-\bar x)/s)|

Parameters and notation

Fn is empirical CDF; x̄,s are estimated parameters with the convention used by the calibration.

Structure of the method

Fit a normal mean and standard deviation to the sample, compute the maximum empirical-CDF discrepancy from that fitted CDF, and use a Lilliefors-specific null calibration. Estimation changes the discrepancy distribution relative to a fully specified Kolmogorov–Smirnov test.

Estimated and nuisance parameters

The normal mean and scale are estimated nuisance parameters, and their precise estimation convention must match the critical-value or simulation algorithm. The discrepancy is a maximum over empirical-CDF jumps; checking only one side of each jump misses the full two-sided statistic.

Settings and design choices

Choose implementation, scale-estimator convention, missing-value policy, significance level, and tabulated/approximate versus bootstrap calibration. The cited R implementation requires more than four observations and uses published approximations that can differ from other software’s simulation-table interpolation.

Fitting and adaptation

For a bootstrap, simulate from the fitted normal model, refit mean and scale in every replicate, and recompute the entire maximum discrepancy. Keeping the original fitted CDF fixed would calibrate a different null. No neural fine-tuning applies; refitting is essential to this test’s definition.

Sensitivity and robustness

Small samples, rounding ties, censoring, and dependence can undermine the continuous-iid calibration. Differences between Python and R p-values may reflect distinct approximation tables even when statistics match. A standard KS p-value after estimating parameters is invalid; a large Lilliefors p-value still does not prove normality.

How to use and calibrate

Use Lilliefors-specific critical values, approximations or a parametric bootstrap refitting mean and variance in every replicate.

Example application

Check normal fit when population parameters are unknown.

Interpretation and pitfalls

Watch out

Ordinary fully specified Kolmogorov–Smirnov p values are invalid after fitting parameters.

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

Normality is assessed for independent observations. For model diagnostics, test residual assumptions in context; do not automatically choose a downstream test based on a preliminary normality p-value.

Python · native

Validated — Executed successfully in the validation environment · needs numpy, scipy

import numpy as np
from scipy import stats
rng = np.random.default_rng(2026)
x=rng.normal(size=60)
print(__import__("statsmodels.stats.diagnostic",fromlist=["lilliefors"]).lilliefors(x,dist="norm"))
Output
(np.float64(0.08521056127801813), np.float64(0.39251721113709154))
R

Validated — Executed successfully in the validation environment · needs nortest

set.seed(2026)
x <- rnorm(60)
print(nortest::lillie.test(x))
Output
	Lilliefors (Kolmogorov-Smirnov) normality test

data:  x
D = 0.065979, p-value = 0.7439

Sources

Statistics guide v4 (historical):
Python: Executed successfully in the validation environment · R: Executed successfully in the validation environment
Reference's record:
Edition 2 review: Python: skip · R: not executed (Rscript unavailable); why not run: Python: Unavailable local dependencies: statsmodels. Python: Not run in the reference's review: Unavailable local dependencies: statsmodels. No installation attempted. R: Reviewed but not run: R wasn't available to the reference's authors.

From the CodeSplash statistics guide (v4), entry 108, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT108.