Shapiro-Wilk Test — Definition, Formula & Example
The Shapiro-Wilk test is a hypothesis test that tells you whether a sample looks like it came from a normal distribution. It produces a single number, W, between 0 and 1. Values near 1 mean the data fit a normal pattern well.
Given an ordered sample , the Shapiro-Wilk test evaluates : the population is normally distributed, against : it is not. The test statistic is the squared weighted combination of the order statistics divided by the sum of squared deviations from the mean. The weights come from the expected values and covariances of standard normal order statistics. The test is left-tailed: you reject when is at or below the critical value, or when the p-value is less than .
Key Formula
Where:
- = The test statistic, with
- = The -th smallest value in the sorted sample
- = Tabulated coefficients that depend only on . They satisfy , so the middle value gets weight 0 when is odd.
- = The sample mean
- = The sample size
Worked Example
Problem: A coffee shop records 5 customer wait times in minutes: 1, 2, 2, 3, 12. For , the Shapiro-Wilk table gives , , and , with and . The critical value at is 0.762. Test whether these wait times come from a normal distribution.
Step 1: The data are already sorted. Find the mean, then add up the squared deviations to get the denominator.
Step 2: Build the numerator by pairing the largest value with the smallest and the second largest with the second smallest. Weight each gap by its coefficient. The middle value has weight 0, so it drops out.
Step 3: Square and divide by the denominator. Then compare the result with the critical value. Small values of count as evidence against normality.
Answer: , which is below the critical value 0.762, so you reject at the 0.05 level. There is convincing evidence that the wait times do not come from a normal distribution. The single long wait of 12 minutes creates strong right skew.
Why It Matters
The t-procedures you learn in AP Statistics assume the data come from a roughly normal population when samples are small. AP Statistics teaches you to check that assumption with a normal probability plot. The Shapiro-Wilk test puts the same check into numbers, and software such as R and Python reports it routinely in college statistics and research.
Common Mistakes
Mistake: Rejecting normality because is large, as if it worked like a z or t statistic where bigger means more extreme.
Correction: measures how closely the data match a normal pattern, so values near 1 support normality. Only small values of give evidence against . Also, with very small samples the test often fails to detect non-normal data, so check a graph as well.
