Normality Test

Tests a sample for normality using the Shapiro–Wilk, Kolmogorov–Smirnov (including the Lilliefors correction), and Anderson–Darling tests, plus a histogram and Q–Q plot.

This page exists due to the efforts of the following people:

Timur

Timur

Created: 2026-11-21 08:25:47, Last updated: 2026-11-21 08:25:47
Creative Commons Attribution/Share-Alike License 3.0 (Unported)

This content is licensed under Creative Commons Attribution/Share-Alike License 3.0 (Unported). That means you may freely redistribute or modify this content under the same license conditions and must attribute the original author by placing a hyperlink from your site to this work https://planetcalc.com/11020/. Also, please do not modify any references to the original work (if any) contained in this content.

This online calculator checks whether a sample is consistent with a normal distribution. It calculates the Shapiro–Wilk, Kolmogorov–Smirnov (including the Lilliefors correction), and Anderson–Darling tests, and also draws a histogram with a normal curve and a normal Q–Q plot.

You can find the formulas and some theory below the calculator.

PLANETCALC, Normality Test

Normality Test

Numbers separated by commas, semicolons, spaces, or newlines. The decimal separator is a period.
If the p-value is less than α, the normality hypothesis is rejected.
The Lilliefors correction is used when the parameters are estimated from the sample.
A priori mean used only for the classical Kolmogorov–Smirnov test.
Standard deviation, not variance; must be greater than zero.
Sample size n
 
Sample mean x̄
 
Sample standard deviation s
 
Maximum likelihood estimate of σ
 
Digits after the decimal point: 6
Conclusion
 
The file is very large. Browser slowdown may occur during loading and creation.
Histogram and normal density
The file is very large. Browser slowdown may occur during loading and creation.
Normal Q–Q plot
The file is very large. Browser slowdown may occur during loading and creation.

What Exactly Is Being Tested

The normal distribution (normal law, Gaussian distribution) is a continuous distribution with the density

f(x)=\frac{1}{\sigma\sqrt{2\pi}}\exp\left(-\frac{(x-\mu)^2}{2\sigma^2}\right),

where \mu is the mean, \sigma is the standard deviation, and \sigma>0. Its graph is a symmetric bell curve centered at \mu. A separate calculator for the normal distribution density and cumulative distribution function is available here: Normal distribution.

Suppose we weigh the same calibration weight twenty times. The scale readings vary slightly: 999.8 g, 1000.1 g, 1000.0 g, and so on. We may assume that the scale's random error is normally distributed. But twenty numbers cannot show us the distribution itself — they can only show how strongly the observations contradict it.

We therefore formulate the null hypothesis H_0: the sample comes from a normal distribution. The alternative hypothesis H_1 states the opposite. For the classical Kolmogorov–Smirnov test with specified parameters, the hypothesis is narrower: it tests the particular distribution N(\mu_0,\sigma_0^2), rather than just any normal distribution.

Each test produces a statistic and a p-value. In other words, the p-value is the probability, assuming H_0 is true, of obtaining a departure from normality as strong as or stronger than the one observed in our sample. It is not the probability that the normality hypothesis is true.

But how do we get a probability from a single number — the test statistic? We need to know the statistic's null distribution, that is, the distribution of values it would have if H_0 were true. Imagine repeatedly drawing new samples of the same size n from a normal distribution and recalculating the statistic each time. We then find the proportion of these values that contradict normality at least as strongly as the value from our sample. That proportion is the p-value.

The direction of the inequality depends on the test: small W values are suspicious for Shapiro–Wilk, whereas large D and A^2 values are suspicious for Kolmogorov–Smirnov and Anderson–Darling. We therefore cannot simply take the area under an ordinary normal curve to the right of every statistic. Each statistic has its own null distribution, which depends on n; for Kolmogorov–Smirnov, it also depends on whether the parameters were estimated from the sample. In practice, the calculator does not simulate thousands of samples: it uses exact formulas where available and published approximations to the null distributions where exact calculation is too difficult. The method used to obtain the p-value is described below for each test.

The p-value is then compared with the chosen significance level \alpha:

  1. If p<\alpha, the normality hypothesis is rejected. Under the chosen conditions, the discrepancy is too large to be considered a plausible random fluctuation.
  2. If p\geq\alpha, the normality hypothesis is not rejected. But neither is it proved: a departure may exist, and the sample may simply be too small to detect it.

What does this mean in practice? If p=0{,}03 and \alpha=0{,}05, normality is rejected. If p=0{,}91, this does not mean a 91% probability of normality. It only means that discrepancies like this one, or more pronounced ones, occur quite often when the null hypothesis is true.

Sample Mean and Two Standard Deviations

For a sample x_1,\ldots,x_n, the calculator computes the sample mean

\bar{x}=\frac{1}{n}\sum_{i=1}^{n}x_i

and the corrected sample standard deviation

s=\sqrt{\frac{1}{n-1}\sum_{i=1}^{n}(x_i-\bar{x})^2},

where n is the sample size. The divisor n-1 is used in the Lilliefors and Anderson–Darling tests.

To draw the normal curve over the histogram, the calculator uses the maximum likelihood estimate of \sigma:

\hat{\sigma}=\sqrt{\frac{1}{n}\sum_{i=1}^{n}(x_i-\bar{x})^2}.

Thus s and \hat{\sigma} differ in their divisors: n-1 and n. The calculator displays both values. For large n, the difference almost disappears, but for small samples it is better not to sweep it under the rug.

Shapiro–Wilk Test

The Shapiro–Wilk test is designed specifically to test normality. First, the sample values are ordered: x_{(1)}\leq x_{(2)}\leq\ldots\leq x_{(n)}. Then the following statistic is calculated1

W=\frac{\left(\sum_{i=1}^{n}a_i x_{(i)}\right)^2}{\sum_{i=1}^{n}(x_i-\bar{x})^2},

where x_{(i)} are the ordered sample values, \bar{x} is the sample mean, and a_i are coefficients that depend on the sample size and are derived from the properties of order statistics of a normal distribution.

The numerator compares the ordered sample with the pattern expected for normal data, while the denominator measures its overall spread. Values of W lie between zero and one; small W values indicate a departure from normality. However, the decision is not based on an arbitrary threshold such as "W>0{,}9 means normal"; it is based on the p-value.

Because departures from normality correspond to small W values, the p-value here is the left tail of the null distribution:

p=P(W\leq W_{\mathrm{obs}}\mid H_0),

where W_{\mathrm{obs}} is the value calculated for our sample. For example, p=0{,}01 means that if H_0 is true, only 1% of samples of the same size will produce a W value this small or smaller.

The calculator applies this test when 3\leq n\leq5000. The exact null distribution of W is very cumbersome, so Royston's approximation is used: 1-W is transformed using a logarithm and coefficients that depend on n onto a normal scale, which is then used to calculate the left-tail probability.2 For n>5000, the test row shows a dash, while the other checks continue to run.

Kolmogorov–Smirnov Test and the Lilliefors Correction

The empirical distribution function is the proportion of observations not exceeding x:

F_n(x)=\frac{1}{n}\sum_{i=1}^{n}I(x_i\leq x),

where I(x_i\leq x) equals one if the condition is true and zero otherwise, and n is the sample size.

The Kolmogorov–Smirnov test (KS) compares the empirical function F_n(x) with the theoretical normal distribution function F(x):

D=\sup_x\left|F_n(x)-F(x)\right|.

Here D is the largest vertical distance between the two distribution functions, and \sup means that the maximum is taken over all possible x. The larger D is, the greater the discrepancy.

And here is an important nuance. Where do the mean and standard deviation for F(x) come from?

  1. The parameters are known in advance. The specified \mu_0 and \sigma_0 are used, giving the classical Kolmogorov–Smirnov test. For example, the technical specification for an instrument may require an error with mean 0 and standard deviation 0.1 g. We are testing this particular model, not fitting it to fresh measurements. For n\leq100, the calculator uses an exact p-value; for larger samples, it uses numerical approximations.
  2. The parameters are estimated from the same sample. Instead of \mu_0 and \sigma_0, we substitute \bar{x} and s. In this case, the Lilliefors test applies. The statistic D looks the same, but its distribution under the null hypothesis is different, and so is the p-value.3 The ordinary Kolmogorov–Smirnov p-value must not be used after fitting parameters; that calculation would be too lenient with the data.

For both versions of the test, large D values are suspicious, so the right tail of the null distribution is used:

p=P(D\geq D_{\mathrm{obs}}\mid H_0),

where D_{\mathrm{obs}} is the observed maximum discrepancy between the distribution functions. But the null distributions are different. In the classical test, the parameters \mu_0 and \sigma_0 are fixed. In the Lilliefors test, the parameters are estimated anew for each hypothetical normal sample, and the distance D is usually smaller because the curve is fitted specifically to that sample. The same numerical value of D can therefore produce different p-values in the two modes.

In other words, the Lilliefors correction does not adjust the number D itself; it corrects the way a decision is obtained from that number. In the calculator, the Lilliefors test is calculated for n\geq5, and its right tail and p-value are found using analytical approximations.

Anderson–Darling Test

The Anderson–Darling test also compares a sample with a theoretical distribution, but gives more weight to its tails. For a normal distribution with the mean and standard deviation estimated from the sample, the statistic is

A^2=-n-\frac{1}{n}\sum_{i=1}^{n}(2i-1)\left[\ln F(x_{(i)})+\ln\left(1-F(x_{(n+1-i)})\right)\right],

where x_{(i)} are the ordered sample values, F is the normal distribution function with parameters \bar{x} and s, and n is the sample size.

Before calculating the p-value, the statistic is corrected for sample size:

A^{2*}=A^2\left(1+\frac{0{,}75}{n}+\frac{2{,}25}{n^2}\right).

The calculator displays the original A^2 in the table but obtains the p-value from the corrected statistic. Large A^{2*} values speak against normality, so the right tail is needed again:

p=P(A^{2*}\geq A^{2*}_{\mathrm{obs}}\mid H_0).

The null distribution of A^{2*} is not normal. Stephens' piecewise approximation is used for it: depending on the interval containing A^{2*}_{\mathrm{obs}}, one of five formulas approximates the required probability.4 The test is calculated for n\geq8.

Histogram with a Normal Curve

A histogram shows how observations are distributed across intervals. The calculator plots it in density units: the height of each bar is

\frac{k}{nh},

where k is the number of observations in the interval, n is the sample size, and h is the interval width. The area of each bar therefore equals the proportion of observations in it, and the total area of the histogram equals one. This allows the density of the normal distribution N(\bar{x},\hat{\sigma}^2) to be superimposed — both quantities use the same scale.

Here is an example. If 4 out of 20 measurements fall into an interval 0.4 g wide, the bar height is 4/(20\cdot0{,}4)=0{,}5. Its area is 0{,}5\cdot0{,}4=0{,}2, so the interval contains 20% of the sample.

The interval width is selected automatically using the Freedman–Diaconis rule:

h=\frac{2\,IQR}{n^{1/3}},\qquad IQR=Q_3-Q_1,

where IQR is the interquartile range, and Q_1 and Q_3 are the first and third sample quartiles. If this width cannot be obtained, for example when the interquartile range is zero, the number of intervals is chosen as \lceil\sqrt{n}\rceil.5

What should you look for? Noticeable asymmetry, several separate peaks, large gaps, and outliers. But do not demand a perfect bell: a small sample from a strictly normal distribution can produce a rather crooked histogram. Randomness is entitled to a few irregularities.

Normal Q–Q Plot

A Q–Q plot (quantile–quantile plot) compares sample quantiles with the quantiles of a theoretical distribution. For a normal Q–Q plot, the calculator plots the points

\left(\Phi^{-1}(p_i),\;x_{(i)}\right),\qquad p_i=\frac{i-0{,}375}{n+0{,}25},\qquad i=1,\ldots,n,

where \Phi^{-1} is the inverse standard normal distribution function and x_{(i)} is the ordered sample. The probabilities p_i are called plotting positions: they specify which theoretical quantile should be paired with the i-th smallest observation.

This formula is the rule proposed by Swedish statistician Gunnar Blom.6 Why the strange numbers 0.375 and 0.25? The simplest choice, p_i=i/n, would give p_n=1 for the last observation, and the corresponding normal quantile \Phi^{-1}(1) would be infinite — a point like that cannot be plotted. Blom's positions stay away from zero and one, are symmetric about 1/2, and closely approximate the expected positions of order statistics from a normal sample.

For example, with n=4, we get p_1\approx0{,}147, p_2\approx0{,}382, p_3\approx0{,}618, and p_4\approx0{,}853. Thus the minimum is paired with approximately the 14.7th percentile and the maximum with the 85.3rd percentile, rather than an infinite point at the end of the distribution.

The reference line passes through the corresponding first and third quartiles of the theoretical and sample quantiles. This choice is more robust to outliers than a line based only on the mean and standard deviation.

How to read the plot:

  1. Points close to the line — no serious visual contradictions to normality. Exact agreement is not required, of course.
  2. A smooth bend — the distribution may be asymmetric.
  3. An S-shaped departure — the sample tails differ from normal tails: they are heavier or lighter.
  4. Individual points far from the overall pattern — possible outliers.
  5. Steps — the data contain many repeated values or the quantity is inherently discrete.

The Q–Q plot is especially useful where a histogram depends on the choice of intervals. It does not replace the tests, but it helps explain how exactly the data differ from normal data.

Calculation Example

Let us keep the calculator's 20 default values — hypothetical measurements of a quantity close to 5. Select \alpha=0{,}05 and the mode that estimates parameters from the sample. The results are as follows:

Test Statistic p-value Decision
Shapiro–Wilk W=0{,}978405 0.911875 Normality is not rejected
Lilliefors D=0{,}102608 0.840087 Normality is not rejected
Anderson–Darling A^2=0{,}216283 0.819790 Normality is not rejected

All p-values are well above 0.05. These data therefore provide no grounds to reject normality. That is not the same as saying that the numbers are known to be normal. The default values can be deleted; they are for illustration only.

What if one test rejects normality and the other two do not? This is no reason to hold a two-to-one vote. Tests differ in their sensitivity to skewness, tails, and other departures, and they have different sample-size restrictions. Look at the Q–Q plot, the histogram, and the nature of the data. The calculator's summary only reports whether at least one applicable test rejects normality; it is a summary of results, not a fourth test with its own p-value.

Applicability Conditions

  1. Observations must be independent. If each measurement depends on the previous one, ordinary p-values may be misleading. For time series, their structure must be taken into account first.
  2. Sample size matters. With small n, a test may miss a real departure from normality. With very large n, it may reject normality because of a departure that is practically insignificant for your task. Consider p-values together with the plots and common sense.
  3. The tests have numerical limits. In this calculator, Shapiro–Wilk applies for 3\leq n\leq5000, Lilliefors for n\geq5, and Anderson–Darling for n\geq8. Classical Kolmogorov–Smirnov requires \mu_0 and \sigma_0>0 to be specified in advance. Some p-values are calculated using approximations, as stated in the notes in the results table.
  4. Identical values are not suitable. If the entire sample consists of one repeated number, the standard deviation is zero and no fitted normal distribution exists. The calculator reports an error in this case.
  5. Do not delete outliers merely to obtain an attractive p-value. First check whether an outlier is a measurement or data-entry error. If the observation is genuine, deleting it changes the original problem.
  6. Rejecting normality is not the end of the analysis. A data transformation, a different distribution model, or nonparametric methods may help. For estimating a mean with a large sample, the central limit theorem often helps. Its connection with confidence intervals is discussed in Constructing confidence intervals.

  1. NIST/SEMATECH. e-Handbook of Statistical Methods. Section “Anderson-Darling and Shapiro-Wilk tests”. NIST ↩

  2. Royston P. Remark AS R94: A Remark on Algorithm AS 181: The W-test for Normality. Applied Statistics, 1995, vol. 44, pp. 547–551. DOI ↩

  3. Dallal G. E., Wilkinson L. An Analytic Approximation to the Distribution of Lilliefors’ Test Statistic for Normality. The American Statistician, 1986, vol. 40, pp. 294–296. DOI ↩

  4. Stephens M. A. EDF Statistics for Goodness of Fit and Some Comparisons. Journal of the American Statistical Association, 1974, vol. 69, pp. 730–737. DOI ↩

  5. Freedman D., Diaconis P. On the Histogram as a Density Estimator: L^2 Theory. Zeitschrift für Wahrscheinlichkeitstheorie und Verwandte Gebiete, 1981, vol. 57, pp. 453–476. DOI ↩

  6. Blom G. Statistical Estimates and Transformed Beta-Variables. New York: John Wiley & Sons, 1958. ↩

URL copied to clipboard
PLANETCALC, Normality Test

Comments