AI Glossary / Statistics and probability / Intermediate

Shapiro-Wilk test

Definition

The Shapiro-Wilk test is a statistical test of whether a sample is compatible with a normal distribution. Its null hypothesis concerns normality, with the normal distribution's mean and variance unspecified. The test compares a weighted combination of ordered observations with their overall variation, producing the statistic W. Small values of W provide evidence against normality. The test is a diagnostic tool, not a certificate that data are normal or that a subsequent analysis is automatically valid.

What it means

Many statistical methods use normality assumptions for errors, differences or sampling distributions. The Shapiro-Wilk test can help investigate an appropriate normality question, but the object being tested must be chosen carefully. Raw outcomes need not be normal for every regression analysis, and pooled data from different groups may look nonnormal even when a conditional error model is reasonable. A p-value describes compatibility with the specified null model under its assumptions, not the probability that normality is true.

How it works

Collect the relevant observations and assess whether independence and a common distribution are plausible. Sort the values, apply sample-size-dependent coefficients derived from normal order statistics and calculate W as the squared weighted sum divided by the sum of squared deviations from the sample mean. Obtain a p-value from a suitable null calibration. Review a normal quantile plot and the substantive consequences of any departure. Software has implementation-specific limits; SciPy warns that p-values may be inaccurate for samples larger than 5,000 even when W is accurate.

Three practical examples

Example 1: A quality analyst examines whether independent measurement errors reasonably follow a normal model. Example 2: An AI experiment checks the distribution of participant-level paired differences before considering a normal-based small-sample analysis. Example 3: A researcher studies residual patterns after fitting a regression, while recognizing that fitted residuals are not simply an independent raw sample. In each case, the diagnostic should support model judgment rather than automatically choose an analysis from a single p-value.

Think of it this way

Think of comparing the spacing of sorted observations with the spacing expected from a normal distribution. An unusually stretched tail or other pattern may look inconsistent with that reference. A small sample can resemble the pattern by chance even when its population differs, while a very large sample can reveal a tiny departure with little practical impact. The comparison therefore needs both statistical and contextual interpretation.

Worked example

For a transparent three-observation illustration, take values 1,2 and 4. At sample size three, W equals the squared range divided by twice the sum of squared deviations from the sample mean. The mean is 7/3 and the squared deviations sum to 14/3. Therefore W = 9/(28/3) = 27/28, approximately 0.96429. For this special sample size, the exact lower-tail null probability is six divided by pi times the quantity arcsine of square root of W minus pi/3, giving approximately 0.63689. At a prespecified 0.05 level, this does not reject normality. It emphatically does not establish normality from three values. Adding ten to every value or multiplying every value by five leaves W unchanged, illustrating its location and scale invariance.

Illustrative case study

In this fictional case study, Harbor Metrics analyses completion-time differences from an AI usability experiment. A normality test does not reject, but the analyst notices that the sample is small and one participant's difference is unusually large. The team inspects the data source, plots the differences and evaluates how sensitive its conclusion is to reasonable analysis choices. It reports the diagnostic as one piece of evidence rather than announcing that the assumption has been proven or deleting the unusual observation merely to improve the p-value.

Common misconceptions and mistakes

Common mistakes include interpreting a large p-value as proof of normality, applying the test to the wrong quantity, and ignoring dependence or ties introduced by rounding. Another error is assuming that rejection makes every normal-based method unusable; robustness depends on the method, sample size and type of departure. Conversely, nonrejection does not validate independence, equal variance or the study design. Constant observations contain no usable variation for the usual statistic and require separate handling.

Business use

Businesses use the test when checking assumptions behind process analyses, experiments and measurement models. AI teams can use it to investigate error or difference distributions, but should also examine plots, outliers and the decision's sensitivity to modeling choices. A rigid test-then-switch workflow can create additional inferential problems. Document the diagnostic, why normality matters for the intended method and whether departures materially affect estimates or uncertainty. Avoid presenting a software-generated p-value as a general data-quality score.

People also ask

Does the test require a known mean or variance?

The usual Shapiro-Wilk test does not; it tests the family of normal distributions.

Is W itself a probability?

No; it is the test statistic, and its p-value depends on sample size and calibration.

Can a huge dataset reject for a negligible departure?

Yes; high power can detect small deviations, so practical consequences still matter.

Can a small sample fail to detect substantial nonnormality?

Yes, because its power is limited.

Check your understanding

What is W for the three values in the worked example?

Answer: 27/28, approximately 0.96429.

Does its p-value around 0.637 prove that the population is normal?

Answer: No; it only fails to reject under the specified test.

What happens to W after adding a constant to all values?

Answer: It remains unchanged.

Does a normality test assess independence?

Answer: No; dependence needs separate consideration.

Related terms

  • Related terms include normal distribution
  • normal quantile plot
  • goodness-of-fit test
  • residual diagnostics
  • Shapiro-Francia test
  • Anderson-Darling test and statistical power

Learn next

Learn next how normal quantile plots reveal tail and asymmetry patterns. Distinguish assumptions about raw observations from assumptions about model errors or paired differences. Study robust estimation and resampling methods with their own assumptions, then practice explaining why a detected departure does or does not materially affect the decision at hand.

More in Statistics and probability

  • Sequential studies - Sequential studies divide an investigation into distinct phases and allow findings from one phase to influence the design or purpose of later phases.
  • Seriousness check - A seriousness check asks research participants to report whether they are participating seriously, rather than merely inspecting a study or providing...
  • Set balancing - Set balancing is the problem of dividing a collection of items into two groups so that specified features are distributed as evenly as possible.
  • Shared models - Shared models are trained machine-learning models made available for reuse by other developers, teams or applications.
  • Siegel - Tukey test - The Siegel-Tukey test is a nonparametric procedure for comparing the spread of two independent samples using specially assigned ranks.
  • Sign test - The sign test is a nonparametric test based on whether observations lie above or below a specified value, or whether paired differences are positive or...

Sources

Sources: SciPy, scipy.stats.shapiro, https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.shapiro.html; Shapiro and Wilk, An analysis of variance test for normality, https://webspace.ship.edu/pgmarr/geo441/readings/shapiro%20and%20wilk%201965%20-%20an%20analysis%20of%20variance%20test%20for%20normality.pdf; SAS, Goodness-of-Fit Tests, https://support.sas.com/documentation/cdl/en/procstat/67528/HTML/default/procstat_univariate_details52.htm. The three-point calculation and fictional case are original illustrations, not evidence of normality in an actual dataset.

Previous: Shaping theorem Next: Shard

  • Home
  • Daily AI Updates
  • Blog
  • AIFBL Academy
  • AI Glossary
  • Products and Tools
  • Store
  • Free CFO AI Prompt Pack
  • About Shihan Sheriff
  • Privacy Policy
  • Terms of Use
  • Refund Policy
  • Cookie Policy
  • Earnings Disclaimer