Home / Shared Math Details / Shared Estimators and Tests / Shapiro-Wilk Test
Shapiro-Wilk Test¶
This page defines the Shapiro-Wilk normality test that Quantum XL uses. It is one of the selectable goodness-of-fit methods wherever a normality check is offered.
Notation¶
| Term | Description |
|---|---|
| \(n\) | number of data values |
| \(x_{(1)} \le x_{(2)} \le \cdots \le x_{(n)}\) | the data sorted in ascending order |
| \(\bar{x}\) | sample mean |
| \(a_i\) | Shapiro-Wilk coefficients from normal order statistics |
| \(W\) | Shapiro-Wilk statistic |
Test statistic¶
\(x_{(1)} \le \cdots \le x_{(n)}\) are the values sorted ascending and \(\bar{x}\) is their mean. The constants \(a_i\) are derived from the expected values and covariances of standard normal order statistics; Quantum XL computes them with Royston's Algorithm AS R94. \(W\) is close to \(1\) when the data follow a normal distribution.
p-value¶
The p-value comes from Royston's normalizing transformation. For \(n = 3\) the exact value \(p = \frac{6}{\pi}\left(\arcsin\sqrt{W} - \frac{\pi}{3}\right)\) is used. For \(4 \le n \le 11\) the statistic is transformed with \(y = -\ln\!\big(\gamma - \ln(1 - W)\big)\), and for \(n > 11\) with \(y = \ln(1 - W)\); in both cases \(y\) is standardized with sample-size-dependent mean and standard deviation polynomials, and the p-value is the upper tail of the standard normal distribution for the resulting \(z\).
The p-value is always exact: Shapiro-Wilk is the one normality test whose reported p-value is never floored or capped, so it never prints with a less-than or greater-than prefix.
Sample size¶
Shapiro-Wilk requires at least 3 values and accepts at most 2000. Both ends are hard limits, and 2000 is the only upper limit among the three normality tests. Above 2000 values the test does not run: no statistic and no p-value are reported, and no message explains the omission. This is easy to hit wherever the sample is every individual observation with all measurement columns pooled, as it is on a control chart with capability attached, where 400 subgroups of 5 already exceed the limit. Anderson-Darling and Kolmogorov-Smirnov have no upper limit and are the alternatives for large samples.
Used by¶
- Summary Statistics: the normality-test section.
- Cpk/Histogram Math Details: the selectable goodness-of-fit method.
- Variable control charts with capability attached: Xbar-R, Xbar-S, I-MR, and I-MR-R/S, when a specification limit or target is entered. See Goodness of Fit for that behavior.
See Also¶
References¶
- Shapiro, S. S., and Wilk, M. B. (1965). An analysis of variance test for normality (complete samples). Biometrika, 52(3/4), 591-611.
- Royston, P. (1995). Remark AS R94: A remark on Algorithm AS 181: The W-test for normality. Journal of the Royal Statistical Society: Series C (Applied Statistics), 44(4), 547-551.
- Royston, P. (1992). Approximating the Shapiro-Wilk W-test for non-normality. Statistics and Computing, 2(3), 117-119.