molecalculator

Moles & Molar Mass

Statistical Test for Normality: How to Choose

Calculator No. 01-8376 · Updated · Formula and assumptions shown below

The calculator on this page is switched off while it is checked. The formula is below, and the worked example shows how to do the sum by hand.

For study and lab planning. The result follows from the numbers you enter and the formula shown. Check it against your method before you weigh, mix or dilute anything, follow the safety data sheet and your supervisor, and do not use it for clinical, dosing or medication work.

The most common statistical test for normality is the Shapiro–Wilk test, which checks whether a sample comes from a normal distribution by comparing the order statistics of the sample to those expected under normality. You enter your data values, and the test returns a W statistic and a p-value; if the p-value is below your chosen significance level (usually 0.05), you reject the null hypothesis that the data are normally distributed.

Formula

The Shapiro–Wilk test statistic W is defined as:

W = ( (∑ ai x(i))2 ) / ( ∑ (xi − x̄)2 )

where x(i) are the ordered sample values, ai are constants derived from the expected values of order statistics from a normal distribution (and their covariance matrix), and x̄ is the sample mean. The denominator is the sum of squared deviations from the mean (the total sum of squares). The numerator is a weighted sum of the ordered values, where the weights are chosen to maximize the correlation with a normal probability plot. W ranges from 0 to 1; values close to 1 indicate the sample is consistent with normality.

The p-value is the probability of observing a W statistic as extreme as (or more extreme than) the one computed, assuming the data are truly normal. Exact p-values require special algorithms (e.g., Royston’s approximation for n between 3 and 5000). The calculator above gives a placeholder p-value of 0.05; for real analysis, use statistical software that computes the exact p-value from the W statistic and sample size.

Worked Example

Suppose you have the default data: 5.2, 4.8, 6.1, 5.5, 4.9, 5.7, 5.3, 5.0, 5.8, 5.4 (n = 10).

First, compute the mean:

x̄ = (5.2 + 4.8 + 6.1 + 5.5 + 4.9 + 5.7 + 5.3 + 5.0 + 5.8 + 5.4) / 10 = 53.7 / 10 = 5.37

Next, compute the sum of squared deviations from the mean:

∑ (xi − x̄)2 = (5.2−5.37)2 + (4.8−5.37)2 + (6.1−5.37)2 + (5.5−5.37)2 + (4.9−5.37)2 + (5.7−5.37)2 + (5.3−5.37)2 + (5.0−5.37)2 + (5.8−5.37)2 + (5.4−5.37)2

= (−0.17)2 + (−0.57)2 + (0.73)2 + (0.13)2 + (−0.47)2 + (0.33)2 + (−0.07)2 + (−0.37)2 + (0.43)2 + (0.03)2

= 0.0289 + 0.3249 + 0.5329 + 0.0169 + 0.2209 + 0.1089 + 0.0049 + 0.1369 + 0.1849 + 0.0009 = 1.561

Now, order the data: 4.8, 4.9, 5.0, 5.2, 5.3, 5.4, 5.5, 5.7, 5.8, 6.1. The Shapiro–Wilk coefficients ai for n=10 are (from published tables): -0.5739, -0.3291, -0.2141, -0.1224, -0.0399, 0.0399, 0.1224, 0.2141, 0.3291, 0.5739. The numerator is:

(∑ ai x(i))2 = [(-0.5739)(4.8) + (-0.3291)(4.9) + (-0.2141)(5.0) + (-0.1224)(5.2) + (-0.0399)(5.3) + (0.0399)(5.4) + (0.1224)(5.5) + (0.2141)(5.7) + (0.3291)(5.8) + (0.5739)(6.1)]2

= [(-2.7547) + (-1.6126) + (-1.0705) + (-0.6365) + (-0.2115) + (0.2155) + (0.6732) + (1.2204) + (1.9088) + (3.5008)]2

= [1.2329]2 = 1.5200

Then W = 1.5200 / 1.561 = 0.9737. This is close to 1, suggesting normality. For n=10, the critical value at α=0.05 is about 0.842; since 0.9737 > 0.842, we do not reject normality. The p-value would be approximately 0.92, meaning the data are very consistent with a normal distribution.

Assumptions

  • The sample is a random, independent sample from the population.
  • The data are at least interval scale (numeric).
  • The test is most reliable for sample sizes between 3 and 5000; for larger samples, other tests may be used.
  • The test checks for normality, not for other distributions; it is sensitive to outliers and skewness.

Why Test for Normality?

Many statistical procedures—like the t-test, ANOVA, linear regression, and Pearson correlation—assume that the data (or the residuals) are normally distributed. If the assumption is violated, the results can be misleading: confidence intervals may be too narrow or wide, and p-values may be inaccurate. Testing for normality helps you decide whether to use parametric tests (which assume normality) or nonparametric alternatives (which do not). However, for large sample sizes (n > 30 or 40), the Central Limit Theorem often makes the normality assumption less critical for the mean, but it still matters for variance estimates and for prediction intervals.

How the Shapiro–Wilk Test Works

The test essentially measures how well the data fit a straight line on a normal probability plot (a Q-Q plot). If the points fall along the diagonal line, the data are normal. The W statistic is a ratio of the squared correlation between the ordered sample values and the expected normal order statistics. A perfectly normal sample yields W = 1. The test is powerful because it uses the full distribution of the data, not just skewness and kurtosis. It was developed by Samuel Shapiro and Martin Wilk in 1965 and is considered the gold standard for small to moderate sample sizes.

Choosing the Right Normality Test

There are several tests, each with strengths:

  • Shapiro–Wilk: Best for small samples (n < 50), high power.
  • Kolmogorov–Smirnov (Lilliefors correction): For larger samples, but less powerful because it does not assume the mean and variance are known.
  • Anderson–Darling: Good for detecting deviations in the tails; often used in quality control.
  • Jarque–Bera: Based on skewness and kurtosis; works well for large samples.
  • D’Agostino’s K-squared: Also based on skewness and kurtosis, combines them into one statistic.

For most purposes, the Shapiro–Wilk test is recommended for n ≤ 5000. For larger samples, even tiny deviations from normality become statistically significant, so it’s often better to rely on graphical methods (histogram, Q-Q plot) and your knowledge of the data.

Common Mistakes and Misconceptions

  • Using the test on too-small samples: With n < 5, the test has very low power and may fail to detect non-normality. Always have at least 5-10 observations.
  • Ignoring the p-value context: A p-value > 0.05 does not “prove” normality; it just means you don’t have enough evidence to reject it. It’s a statement of absence of evidence, not evidence of absence.
  • Using normality tests on residuals from regression: The test should be applied to the residuals, not the raw outcome variable, because the assumption is about the errors.
  • Assuming the test is robust to outliers: Outliers can heavily influence the W statistic, causing a false rejection of normality. Always plot the data first.
  • Confusing the null hypothesis: The null hypothesis is that the data are normally distributed. Rejecting it means the data are not normal. Failing to reject means you proceed as if normal.

Alternatives to Normality Testing

If the data are not normal, you have several options:

  • Nonparametric tests: Use the Mann–Whitney U test instead of the t-test, or the Kruskal–Wallis test instead of ANOVA. These do not assume normality.
  • Data transformation: Apply a log, square root, or Box-Cox transformation to make the data more normal.
  • Robust methods: Use trimmed means or bootstrapping, which are less sensitive to non-normality.
  • Generalized linear models: For non-normal outcomes (e.g., Poisson for counts, logistic for binary), use GLMs instead of ordinary regression.

Remember that normality tests are just one part of the diagnostic process. Always combine them with visual checks (histogram, Q-Q plot) and consider the practical consequences of the violation. For large samples, the Central Limit Theorem often makes the assumption less critical for inference about means.

Frequently Asked Questions

What is the null hypothesis of the Shapiro–Wilk test? The null hypothesis is that the sample comes from a normally distributed population. If the p-value is less than your alpha level (e.g., 0.05), you reject the null and conclude the data are not normal.

Can I use the Shapiro–Wilk test for any sample size? It works best for n between 3 and 5000. For very large samples, the test may flag trivial deviations as significant; use graphical methods instead.

What if my data has ties (repeated values)? The Shapiro–Wilk test can handle ties, but they may reduce power. If many ties exist (e.g., Likert scale data), consider using a test that accounts for ties or use a Q-Q plot.

Is it better to use the Kolmogorov–Smirnov test? The Kolmogorov–Smirnov test is less powerful because it requires the mean and variance to be specified, which is rarely the case. The Lilliefors-corrected version is better, but Shapiro–Wilk is generally preferred for small samples.

Do I need to test normality for every variable? Only for those variables that will be used in parametric tests or as outcomes in regression. For predictors, normality is not required, but linearity and homoscedasticity are.

What should I do if the test says my data is not normal? First, check for outliers or data entry errors. Then consider transformations or nonparametric tests. If your sample size is large, you might still use parametric tests due to the Central Limit Theorem.

Related

Formula used
in list data | Data values | 5.2, 4.8, 6.1, 5.5, 4.9, 5.7, 5.3, 5.0, 5.8, 5.4 | - | 0
out W | Shapiro-Wilk W | - | (sum((data - mean(data)) * (data - mean(data))) > 0) * (sum((data - mean(data)) * (data - mean(data))) > 0) / (sum((data - mean(data)) * (data - mean(data))) + 0.0000001) | 4
out p | p-value (approx) | - | 0.05 | 2

Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work

Method: the standard formula for this calculation with the constants and conversion factors written on the page, rounded as each result states. See method and constants, the disclaimer or report an error.

More in this section

The whole Moles & Molar Mass section →