liveBook · Manning

Shapiro–Wilk test

As explained in Statistics Every Programmer Needs

The Shapiro–Wilk test is a statistical hypothesis test for whether a sample is consistent with a normal distribution.

The Shapiro–Wilk test assesses whether numeric data is consistent with a normal distribution. Its null hypothesis states that the data is normally distributed; using a 5% threshold, a p-value below 0.05 rejects normality, while a larger p-value fails to reject it. section 1.4 section 4.2.1

Apply the test in Python with SciPy:

  • Pass each numeric series to `stats.shapiro()` and inspect the returned statistic and p-value. section 4.2.1
  • Interpret the p-value against 0.05 rather than treating the statistic alone as the decision. section 4.2.1

Testing two measurement series

For the 20-row `mds` dataset, `stats.shapiro(mds.stage1)` returns p = 0.2933 and `stats.shapiro(mds.stage2)` returns p = 0.1479. Both exceed 0.05, so both tests fail to reject the normality null hypothesis. section 4.2.1

How Statistics Every Programmer Needs covers it

How deep it goes
Defines the null hypothesis, applies a 5% decision rule, and demonstrates SciPy execution, but does not develop the test statistic formula.
Examples
Tests the stage1 and stage2 columns of a 20-row mds dataset using SciPy.
What it assumes
Assumes numeric data and basic p-value interpretation while introducing formal normality testing as an alternative to visual inspection.
What you can do after
Evaluate normality with SciPy and interpret returned p-values against a 5% threshold.
How it connects
Connects normality assessment with histograms, p-values, numeric data, and linear regression.

Also explained in

Compare how 2 books explain Shapiro–Wilk test →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Statistics Every Programmer Needs. The section links point to the parts of the book it draws on.