Skip to content
K Knidox Search…
Statistics · Inference

Shapiro–Wilk Test

Test a sample for normality, with the Q–Q plot that shows what kind of departure you have.

Separate values with commas, spaces or newlines. Between 3 and 5,000 values.
Significance level α
W
0.96909Consistent with normal

1 is a perfectly straight Q–Q line

p-value
0.7354

against α = 0.05

n
20

values in the sample

p = 0.7354 is above α, so there is no evidence against normality. That is not proof the data is normal — with n = 20 the test may simply lack the power to see a modest departure.

Q–Q plot

Sorted data against normal scores
your sorted valueswhere a normal sample would sithorizontal axis: normal score · vertical axis: your value
Try a shape — tap to load

The Shapiro–Wilk test asks whether a sample could plausibly have come from a normal distribution. W measures how closely the sorted values track the straight line a normal sample would follow: 1 is a perfect fit, and a p-value below α is evidence against normality.

W is a Q–Q plot reduced to one number

Sort your sample. A normal sample of that size would, on average, have its ith smallest value at a predictable place — the normal score for that position. Plot your sorted values against those scores and a normal sample gives a straight line. W is essentially the squared correlation of that plot, rescaled: it is the ratio of the best linear estimate of the variance to the ordinary sample variance, and those two agree only when the points really do lie on a line.

This is why the test and the picture belong together. W tells you whether the sample departs from normal; the Q–Q plot tells you how. A smooth curve means skew, both ends pulling away from the line means heavy tails, and a single point far off the line means an outlier — three quite different problems that produce the same small p-value.

Why it beats the alternatives

Shapiro–Wilk is generally the most powerful of the common normality tests, which is why R, SPSS and SciPy all offer it and why it is usually the one reported. The Kolmogorov–Smirnov test, its main rival, is substantially weaker against realistic alternatives — and in its textbook form it assumes you knew the mean and variance in advance rather than estimating them from the sample, which is almost never true.

W = (Σ aᵢ x(ᵢ))² ÷ Σ (xᵢ − x̄)²

x(ᵢ) is the ith smallest value; the weights aᵢ come from the expected normal order statistics

  1. 1
    Sort the sample. W is built from the order statistics, so the ordering is the whole input.
  2. 2
    Work out the normal scores. For position i out of n, that is Φ⁻¹((i − 0.375) ÷ (n + 0.25)) — where a normal sample’s ith value would sit.
  3. 3
    Turn the scores into weights. Royston’s algorithm normalises them and corrects the two most extreme, which is what makes W comparable across sample sizes.
  4. 4
    Form the ratio. The squared weighted sum over the ordinary sum of squares. W lies between 0 and 1.
  5. 5
    Read the p-value, then look at the plot. A p above α leaves normality intact. A p below it means look at the Q–Q plot to see whether you have skew, heavy tails or one stray point.

How often the test catches a uniform distribution

Share of samples rejected at α = 0.05, from 2,000 simulated uniform samples at each size. Power depends on sample size, not just on how non-normal the data is.

Sample sizeRejected at α = 0.05
2020%
3040%
5075%
10099.6%
200100%

The two ways this test misleads people

The first is reading a non-significant result as proof of normality. It is not. The table above measures the problem directly: a uniform distribution is about as un-bell-shaped as a bounded distribution gets, and at n = 20 this test misses it four times out of five. A large p-value with a small sample means you have not detected a departure, which is a much weaker statement than there being none.

The second is the mirror image. With a few thousand observations the test detects departures so slight that nothing downstream would notice them, and flags perfectly workable data as non-normal. This matters less than people fear, because the procedures that assume normality — t-tests, ANOVA, regression — rely on the sampling distribution of the mean rather than of the data, and the central limit theorem takes care of that as n grows. The irony is real: the test becomes most sensitive exactly when the assumption stops mattering.

The practical position most statisticians take is to treat the Q–Q plot as the primary tool and the test as a sanity check on it. The plot shows magnitude and kind of departure; the test converts that into a number whose meaning depends heavily on n. This page reports W and p to the same precision as R and SciPy, using Royston’s AS R94 algorithm, and draws the plot alongside so you can read both.

What does the Shapiro–Wilk test tell me?
Whether your sample is consistent with having come from a normal distribution. The null hypothesis is normality, so a small p-value is evidence against it.
What is a good value of W?
W runs from 0 to 1, and 1 means the sorted data lies exactly on the line a normal sample would follow. There is no universal cutoff — the p-value accounts for sample size, which a raw W does not.
Does a large p-value prove my data is normal?
No. It means no departure was detected. At n = 20 this test misses a uniform distribution about 80% of the time, so a non-significant result from a small sample says very little.
Why does it reject my large dataset?
Because power grows with n. At a few thousand observations it detects departures too small to affect anything. Look at the Q–Q plot to judge whether the departure has any practical size.
How is it different from Kolmogorov–Smirnov?
Shapiro–Wilk is built specifically for normality and is considerably more powerful. The textbook K–S test also assumes the mean and variance were known in advance rather than estimated from the sample, which is rarely the case.
How do I read the Q–Q plot?
Points on the dashed line mean normal. A smooth curve means skew, both ends bending away means heavy tails, and one point far off on its own means an outlier.
What should I do if my data is not normal?
It depends on why. Transform it if the problem is skew, investigate if it is an outlier, or switch to a rank-based test such as Mann–Whitney or Kruskal–Wallis, which assume nothing about the shape.