Kolmogorov-Smirnov Test for Normality

Hypothesis Testing

Definition 1: Let x1,…,xn be an ordered sample with x1 ≤ … ≤ xn and define Sn(x) as follows:


Now suppose that the sample comes from a population with cumulative distribution function F(x) and define Dn as follows:


Observation: It can be shown that Dn doesn’t depend on F. Since Sn(x) depends on the sample chosen, Dn is a random variable. Our objective is to use Dn as a way of estimating F(x).

The distribution of Dn can be calculated (see Kolmogorov Distribution), but for our purposes now the important aspect of this distribution are the critical values. These can be found in the Kolmogorov-Smirnov Table.

If Dn,α is the critical value from the table, then P(Dn ≤ Dn,α) = 1 – α. Dn can be used to test the hypothesis that a random sample came from a population with a specific distribution function F(x). If


then the sample data is a good fit with F(x).

Also from the definition of Dn given above, it follows that

image3581 image3583 image3582

Thus Sn(x) ± Dn,α provides a confidence interval for F(x)

Example 1: Determine whether the data represented in the following frequency table is normally distributed.

Frequency table KS test

Figure 1 – Frequency table for Example 1

This means that 8 elements have an x value less than 100, 25 elements have an x value between 101 and 200, etc. We need to find the mean and standard deviation of this data. Since this is a frequency table, we can’t simply use Excel’s AVERAGE and STDEV functions. Instead we first use the midpoints of each interval and then use an approach similar to that described in Frequency Tables as follows:

Frequency table mean variance

Figure 2 – Calculating mean and standard deviation for data in frequency table

Thus, the mean is 481.4 and the standard deviation is 155.2. We can now build the table that allows us to carry out the KS test, namely:

Kolmogorov-Smirnov test Excel

Figure 3 – Kolmogorov-Smirnov test for Example 1

Columns A and B contain the data from the original frequency table. Column C contains the corresponding cumulative frequency values and column D simply divides these values by the sample size (n = 1000) to yield the cumulative distribution function Sn(x)

Column E uses the mean and standard deviation calculated previously to standardize the values of x from column A. E.g. the formula in cell E4 is =STANDARDIZE(A4,N$5,N$10), where cell N5 contains the mean and cell N10 contains the standard deviation. Column F uses these standardized values to calculate the cumulative distribution function values assuming that the original data is normally distributed. E.g. cell F4 contains the formula =NORMSDIST(E4). Finally column G contains the differences between the values in columns D and F. E.g. cell G4 contains the formula =ABS(F4—D4). If the original data is normally distributed these differences will be zero.

Now Dn = the largest value in column G, which in our case is 0.0117. If the data is normally distributed then the critical value Dn,α will be larger than Dn. From the Kolmogorov-Smirnov Table we see that

Dn,α = D1000,.05 = 1.36 / SQRT(1000) = 0.043007

Since Dn = 0.0117 < 0.043007 = Dn,α, we conclude that the data is a good fit with the normal distribution.

Example 2: Using the KS test, determine whether the data in Example 1 of Graphical Tests for Normality and Symmetry is normally distributed.

We follow the same procedure as in the previous example to obtain the following results. Since the frequencies are all 1, this example should be a bit easier to understand.

KS test Excel

Figure 4 – KS test for data from Example 2

The Kolmogorov-Smirnov Table shows that the critical value Dn,α = D15,.05 = .338

Since Dn = 0.1874988 < 0.338 = Dn,α, we conclude that the data is a reasonably good fit with the normal distribution (more precisely that there is no significant difference between the data and data which is normally distributed). Note that is not the same conclusion we reached from looking at the histogram and QQ plot.

Real Statistics Excel Function: The following function is provided in the Real Statistics Resource Pack:

KSCRIT(n, α, tails) = the critical value of the Kolmogorov-Smirnov test for a sample of size n, for the given value of alpha (default = .05) and tails = 1 (one tail) or 2 (two tails, default), based on the KS Table.

KSPROB(x, n, tails, iter) = an approximate p-value for the KS test for  value equal to x for a sample of size n and tails = 1 (one tail) or 2 (two tails, default) based on a linear interpolation of the values in the Kolmogorov-Smirnov Table, using iter number of iterations (default = 40).

Note that the values for α in the Kolmogorov-Smirnov Table range from .01 to .2 (for tails = 2) and .005 to .1 for tails = 1. If the p-value is less than .01 (tails = 2) or .005 (tails = 1) then the p-value is given as 0 and if the p-value is greater than .2 (tails = 2) or .1 (tails = 1) then the p-value is given as 1.

For Example 2, KSCRIT(15, .05, 2) = .338 (the same as given in cell H21 of Figure 4). Also note that the p-value = KSPROB(H20, B21) = KSPROB(0.1874988, 15) = 1 (meaning that p-value > .2), and so once again we can’t reject the null hypothesis that the data is normally distributed.

If the value of Dn had been .35 in Example 2, then Dn = .35 > .338 = Dcrit, and so we would have rejected the null hypothesis that the data is normally distributed. In this case we would have seen that p-value = KSPROB(.35,15) = .0427, which once again leads us to reject the null hypothesis.

Kolmogorov Distribution

As referenced above, the Kolmogorov distribution can be useful in conducting the Kolmogorov-Smirnov test. Click here for more information about this distribution, including some useful functions provided by the Real Statistics Resource Pack.

Lilliefors Test

When the population mean and standard deviation for the Kolmogorov-Smirnov Test is estimated from the sample mean and standard deviation, as was done in Example 1 and 2, then the Kolmogorov-Smirnov Table yields results that are too conservative. More accurate results can be derived from the Liiliefors Table as described in the Lilliefors Test for Normality.

23 Responses to Kolmogorov-Smirnov Test for Normality

  1. Renato says:

    Dear Sir:
    I am looking for a test to compare if one sub-sample of size “n” taken from a sample of size “N” (source sample), with n<<N, has the same attributes of the source sample.
    Is Kolmogorov-Smirnov the best test?
    The source sample is a multimodal distribution (fish size frequencies); and I have some doubts about how to construct the accumulative sample to make the KS test.
    Tha data is in a table of frequencies by ranges of size
    Thanks for your answer


  2. Juan Pablo Góngora says:

    Hi, the spss software use the Z K-S = D*SQRT(n), and a P-value, but, i can´t calculate the result of the p-value, is not the probablility of the normal distribution.
    Example, n = 20 D = .416, ZK-S =.416*SQRT(20) = 1.861 SPSS P-value (two sided) = .002.
    But, 2*(1-NORMSDIST(1.861)) is not .002
    Do you know how is the p-value calculated?
    Tks a lot
    PD. Sorry, mi english is not the best

  3. Sandeep R says:

    hello sir, i found this article very helpful. i need to fit log normal distribution either from chi square or K-S test. you have explained only normal distribution. please explain log normal distribution also.
    here is my test data
    mean= 5.1439
    δ= 0.2506
    median= 4.99
    σlnz = 0.247

    interval observed frequency
    1.81 2.759 9
    2.759 3.708 61
    3.708 4.657 116
    4.657 5.606 155
    5.606 6.555 120
    6.555 7.504 42
    7.504 8.453 7
    8.453 9.402 2
    9.402 10.351 2
    10.351 11.3 3
    sum= 517

    • Charles says:

      The procedure for using the K-S test with the log normal distribution is pretty much the same as for the normal distribution. E.g. in Figure 3, you won’t need the E column. Simply enter the formula for the log-normal distribution in column F. E.g. cell F4 would contain a formula like =LOGNORMDIST(A4,N5,N10). The rest is the same as in the examples provided on the webpage.

      • Sandeep R says:

        thank you very much sir for your reply.
        sir i have one more doubt, should we use “mean and standard deviation” or “Median and σlnz in lognormal distribution?

        • Charles says:

          If I understand your original question correctly, then you should use the mean and std dev, esp. since Excel has the LOGNORM.DIST function available which use these two parameters. Why do you think the median and σlnz might be good choices? Perhaps this is correct and I am not answering the right question.

  4. Sally says:

    hai, may I know what the p-value mean by and how to find the p-value of kolmogorov-smirnov ?

    • Sally says:

      besides that is it possible to use the statistical value of other distribution as a critical value to find the p-value of KS test?
      for example, use the z value of normal distribution to find the p-value by KS test.

      • Charles says:

        Sorry, but I don’t understand your question. In any case I will be adding the KS p-value shortly.

    • Charles says:

      I am revising the KS part of the website/software and will add the p-value. Stay tuned.

    • Charles says:

      I have now provided a way of calculating the p-value for the KS test, using the functions KSPROB and KSDIST. These are available in the latest release of the Real Statistics Resource Pack (Rel 2.15).

  5. Kevin says:


    I am trying to determine if Rokeach value survey (RVS) responses for two different groups are statistically significant. The RVS has subjects rank 18 values in order of importance to them. I have calculated the mean response for each value within each group and ordered them from most important (lowest mean) to least important (highest mean). I was told I could use the Kolmogorov-Smirnov Test to determine if differences in mean value rankings between groups are statistically significant.
    I would appreciate an explanation of this process in Excel.

    Thank you in advance,
    Kevin, Excel expert, stats neophyte

    P.S. I have learned more practical statistics from your site than my undergrad and masters professors have been able to drill into me… Well done, Sir!

    • Charles says:


      It is good to hear that the site has been helpful. My goal was exactly as you stated, to help people make practical use of (and understand) statistics in the environment is probably the most available for most people, namely Excel.

      If your goal is to determine whether there is a significant difference between the means of the two groups, you probably want to use the t test (if the data in the two groups are normally distributed) or the Mann-Whitney test if they are not. You could also use the two-sample Kolmogorov-Smirnov Test to determine whether the two groups of data come from the same population. I have already described the one sample Kolmogorov-Smirnov Test on the website, but not the two sample test.

      Fortunately, I have just implemented the two sample test in the Real Statistics Resource Pack (Release 2.15) and have written the description for the website (including two examples). I plan to release these in the next couple of days. Stay tuned.


    • Charles says:

      The two-sample KS test is now included in the Real Statistics Resource Pack. The procedure is described on the webpage http://www.real-statistics.com/non-parametric-tests/two-sample-kolmogorov-smirnov-test/.

  6. zohreh says:

    Hi all,
    I am trying to fit an appropriate probability distribution with my data. I have known that I can use K-S test, but my problem is that, as I am going to use MATLAB or EXCEL softwares for this purpose, I do not know how I can use these softwares for this test. My problem is that I have not ever seen any example of this test for exponential or other distributions rather than normal and lognormal distributions. How can I decide whether for example lognormal distribution is appropriate or exponential distribution?
    Thank you very much for your help inn advance.

  7. Cathy says:

    Can we use the Kolmogorov Smirnov test if we want to know whether the data follow a
    binomial distribution?

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>