Skip to content

ADescribe · Guide test 111

Pearson chi square normality test

Compares binned frequencies with frequencies expected under a fitted normal distribution.

Runs in CodeSplashPython (calls R) example not runR 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 = Pearson χ².

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 · Pearson chi-square 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

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

The formula

P=∑j=1k(Oj−n/k)2n/k,ν=k−3P = \sum_{j=1}^{k}\dfrac{(O_j-n/k)^2}{n/k},\qquad \nu = k-3

With your numbers

P=13.55,k=9,ν=6P = 13.55,\quad k = 9,\quad \nu = 6
kk
number of equiprobable classes, ⌈2n^{2/5}⌉
OjO_j
observed count in class j
ν\nu
k − 1 minus the two estimated parameters

The verdict

P(6) = 13.55, p = .035

p ≤ α = .050: reject H₀

Binning throws information away, so it is the weakest normality test here; it is the template for χ² goodness of fit with estimated parameters.

Statistic
13.550
p-value
0.0351
Pearson chi-square normality test on Sample: n = 40: P(6) = 13.55, p = .035. The p-value is below α = .050, so the data are hard to reconcile with H0.

Pearson chi-square normality test on Sample: n = 40: P(6) = 13.55, p = .035. The p-value is below α = .050, so the data are hard to reconcile with H₀.

Question and hypotheses

H0: observations follow a normal distribution.

Assumptions

Independent observations; prespecified binning or a justified data-dependent binning scheme; enough expected counts.

Formula

X2=∑b=1B(Ob−Eb)2EbEb=n[Φ((ub−μ^)/σ^)−Φ((lb−μ^)/σ^)]\begin{gathered}X^2=\sum_{b=1}^{B}\frac{(O_b-E_b)^2}{E_b}\\[5pt] E_b=n[\Phi((u_b-\widehat\mu)/\widehat\sigma)-\Phi((l_b-\widehat\mu)/\widehat\sigma)]\end{gathered}

Parameters and notation

B bins with endpoints lb,ub. Estimation method and bin selection determine the valid reference; B−3 is conventional when two parameters are appropriately fitted to grouped counts.

Structure of the method

Create bins, compute observed frequencies, estimate normal probabilities between bin boundaries and sum Pearson count discrepancies. Binning and normal-parameter estimation are integral steps in the procedure; their order and data dependence determine which chi-square approximation is justified.

Estimated and nuisance parameters

Normal mean/scale are nuisance quantities. Observed and expected bin counts are computed summaries. Bin boundaries may be fixed scientifically or generated by a declared rule, but are not model weights.

Settings and design choices

Select the number of bins, boundary rule, pooling of sparse bins, estimation method and adjusted versus unadjusted reference. More bins expose localized misfit but reduce expected counts and can undermine approximation accuracy.

Fitting and adaptation

For reliable custom calibration, simulate from the fitted normal model, repeat parameter fitting, recreate any adaptive boundaries and recount every replicate. Do not merely subtract two degrees of freedom after arbitrary preprocessing. New data require the same fitting/bucketing rule, not transferred fitted counts. Record bins and expected frequencies with the result.

Sensitivity and robustness

Results can change materially with bin origin and width. Very sparse expected cells, zero fitted probabilities and adaptive bin searches require special handling. Ungrouped mean/SD estimates do not automatically yield the textbook grouped-data chi-square reference; the source documentation explicitly distinguishes these cases.

How to use and calibrate

Use the source’s adjusted calibration or bootstrap the entire fitting/binning procedure.

Example application

Assess a normal model when data are available as grouped frequencies.

Interpretation and pitfalls

Watch out

B−3 is not automatically exact when parameters are estimated from ungrouped data and bins are adaptive.

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 · invokes R

Not run — Executed end to end through Rscript · needs Python standard library + Rscript; R packages: nortest

# 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 <- rnorm(60)
print(nortest::pearson.test(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

Validated — Executed successfully in the validation environment · needs nortest

set.seed(2026)
x <- rnorm(60)
print(nortest::pearson.test(x))
Output
	Pearson chi-square normality test

data:  x
P = 9.3, p-value = 0.3176

Sources

Statistics guide v4 (historical):
Python: Executed end to end through Rscript · R: Executed successfully in the validation 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 111, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT111.