How to Use the Kolmogorov–Smirnov Test Calculator
This Kolmogorov-Smirnov test calculator allows you to perform one-sample and two-sample K-S tests, including a normality test with the Lilliefors correction. You can enter raw data manually or upload an Excel or CSV file containing the observations you want to analyze.
Before entering your data, select the type of test you want to perform and specify the significance level (α). By default, the calculator uses α = 0.05.
Option 1: Enter Data
Use this option when you have numerical observations that you want to enter or copy directly into the calculator.
To perform the Kolmogorov–Smirnov test using this option:
- Select the appropriate test under Type of Test.
- Enter your preferred significance level, α.
- If you selected the one-sample test against a specified distribution, choose the reference distribution and enter its parameters.
- Select Enter Data under Data Input.
- Enter or paste the observations into the Sample Data field. For the two-sample K-S test, enter the observations for each sample separately.
- Click Calculate to perform the test.
The calculator automatically computes the K-S test statistic (D), p-value, and hypothesis-testing decision.
Option 2: Upload Excel or CSV
If your data are stored in an Excel or CSV file, you can upload the dataset instead of entering observations manually.
To perform the test:
- Select the type of K–S test and specify the significance level, α.
- Select Upload Excel / CSV under Data Input.
- Click Choose File and upload your dataset.
- Review the data preview and select the appropriate worksheet if your Excel file contains multiple sheets.
- Choose how your data are arranged:
- Test selected numeric columns: Select one or more numerical variables for a normality or one-sample K-S test.
- Test separately within groups: Select the grouping variable and the numerical variables you want to test.
- Samples in separate numeric columns: Select the two columns containing your samples for a two-sample K-S test.
- Grouping column + numeric outcome: Select a grouping variable containing two groups and the corresponding numerical outcome.
- Click Calculate to obtain the results.
In both input methods, the calculator returns the D statistic, D⁺, D⁻, p-value, sample size, and hypothesis-testing decision. It also provides an APA-style report that you can copy and paste into your research report or assignment.
Note. When you select multiple numerical variables or groups, the calculator summarizes their results in a table.
What Is the Kolmogorov-Smirnov Test?
The Kolmogorov-Smirnov test, commonly abbreviated as the K-S test or KS test, is a nonparametric statistical test used to determine whether a sample follows a specified continuous distribution or whether two independent samples come from the same population distribution.
The test works by comparing cumulative distribution functions (CDFs). A cumulative distribution function gives the probability that a random variable is less than or equal to a specified value.
For example, suppose a researcher wants to determine whether the examination scores of students follow a normal distribution. The researcher can use the one-sample Kolmogorov–Smirnov test with an appropriate normality correction to examine whether the observed scores differ significantly from a normal distribution.
Similarly, suppose a researcher wants to determine whether the distributions of household income differ between two communities. Since the study involves two independent samples, the researcher can use the two-sample Kolmogorov–Smirnov test.
In both cases, the test produces a statistic denoted by D, which measures the maximum difference between the cumulative distributions being compared.
A larger D value indicates a greater difference between the distributions. However, we use the corresponding p-value to determine whether the observed difference is statistically significant.
Types of Kolmogorov-Smirnov Tests
There are two main types of Kolmogorov-Smirnov tests: the one-sample K-S test and the two-sample K-S test. The one-sample test can also be adapted to assess normality when the population mean and standard deviation are unknown.
This calculator supports the following three options.
1. Normality Test (Lilliefors Correction)
Use this option when you want to determine whether a sample comes from a normally distributed population but do not know the population mean and standard deviation. In this case, the calculator estimates the mean and standard deviation from the sample and applies the Lilliefors correction when calculating the p-value. The correction is necessary because the ordinary Kolmogorov-Smirnov test assumes that the theoretical distribution has been fully specified before examining the data.
For example, if you have collected the examination scores of 100 students and want to test whether the scores follow a normal distribution, you can select Normality Test (Lilliefors Correction).
This option requires at least four valid numerical observations.
2. One-Sample Kolmogorov-Smirnov Test
The one-sample K–S test is used to determine whether a sample comes from a specified continuous probability distribution. For this test, you must specify the reference distribution and its parameters independently of the observations being tested.
The calculator supports the following distributions:
- Normal distribution: Enter the population mean (μ) and standard deviation (σ).
- Uniform distribution: Enter the lower and upper bounds of the distribution.
- Exponential distribution: Enter the rate parameter (λ).
For example, suppose a machine is designed to produce measurements following a normal distribution with a mean of 50 and a standard deviation of 5. You can use the one-sample K-S test to determine whether the observed measurements are consistent with this specified distribution.
You can learn more about these distributions using the Normal Distribution Calculator, Uniform Distribution Calculator, and Exponential Distribution Calculator.
3. Two-Sample Kolmogorov-Smirnov Test
The two-sample K–S test is used to determine whether two independent samples come from the same continuous population distribution. Unlike the one-sample test, you do not need to specify a theoretical probability distribution. Instead, the test compares the empirical cumulative distributions of the two samples and calculates the maximum difference between them.
For example, a researcher can use the two-sample K-S test to determine whether the distributions of waiting times differ between two hospitals.
The test examines differences in the entire distribution, including its location, spread, and shape. Therefore, a significant result does not necessarily mean that the population means or medians differ.
Kolmogorov-Smirnov Test Formula
In most cases, you will not need to calculate the Kolmogorov-Smirnov test manually. However, it is useful to understand how the test statistic is obtained.
The formula depends on whether you are performing a one-sample or two-sample K-S test.
1. One-Sample K-S Test Formula
The one-sample Kolmogorov-Smirnov test statistic is calculated using:
D = max |Fₙ(x) − F₀(x)|
Where:
- D = Kolmogorov-Smirnov test statistic
- Fₙ(x) = Empirical cumulative distribution function of the sample
- F₀(x) = Cumulative distribution function of the specified theoretical distribution
- max = Maximum absolute difference between the two cumulative distribution functions
The empirical cumulative distribution is calculated from the observed data, while the theoretical CDF is obtained from the specified distribution.
The test statistic represents the largest vertical distance between these two cumulative distribution functions.
2. Two-Sample K–S Test Formula
For the two-sample test, the formula is:
D = max |F₁(x) − F₂(x)|
Where:
- F₁(x) = Empirical cumulative distribution function of Sample 1
- F₂(x) = Empirical cumulative distribution function of Sample 2
- D = Maximum absolute difference between the two cumulative distributions
The calculator also returns D⁺ and D⁻, which measure the largest positive and negative differences between the cumulative distribution functions.
The final test statistic is obtained using D = max(D⁺, D⁻). Once D has been calculated, the appropriate sampling distribution is used to obtain the p-value.
Since the p-value calculations can be complicated, particularly for small samples, you can use this calculator to perform the test and focus on interpreting the results.
Assumptions of the Kolmogorov-Smirnov Test
Before performing the Kolmogorov-Smirnov test, make sure your data meet the following requirements:
- Numerical observations: The data should contain quantitative measurements.
- Independent observations: Observations within each sample should be independent.
- Continuous distributions: The standard K–S test assumes continuous distributions. Repeated values and discrete data may affect the accuracy of the usual p-value calculations.
- Independent samples: For a two-sample K–S test, the two groups must be independent.
- Specified distribution parameters: When performing the ordinary one-sample K-S test, the reference distribution parameters should be known independently of the sample.
If you want to test normality but have to estimate the population mean and standard deviation from the observations, select the Lilliefors-corrected normality test instead.
Note. The standard k-S test is not designed for paired observations. If your data consist of repeated measurements on the same participants, you need a method that accounts for the dependence between observations.
Kolmogorov-Smirnov Test Hypotheses
Like other statistical hypothesis tests, the Kolmogorov-Smirnov test involves a null hypothesis and an alternative hypothesis.
The hypotheses depend on whether you are performing a one-sample or two-sample test.
For the one-sample Kolmogorov-Smirnov test, the hypotheses are:
- Null hypothesis (H₀): The population follows the specified continuous distribution.
- Alternative hypothesis (H₁): The population does not follow the specified continuous distribution.
However, for the two-sample Kolmogorov–Smirnov test, the hypotheses are:
- Null hypothesis (H₀): The two population distributions are identical.
- Alternative hypothesis (H₁): The two population distributions are not identical.
To determine whether there is sufficient evidence to reject the null hypothesis, we compare the calculated p-value with the significance level (α).
How to Interpret Kolmogorov-Smirnov Test Results
The Kolmogorov-Smirnov test produces a D statistic and a corresponding p-value. The D statistic measures the maximum difference between the cumulative distribution functions being compared. It ranges from 0 to 1, with larger values indicating greater differences.
However, there is no single D value that determines whether a result is statistically significant. The decision depends on the p-value and sample size.
At α = 0.05, the decision rules are:
- If p < 0.05: Reject the null hypothesis. There is sufficient evidence that the distributions differ.
- If p ≥ 0.05: Fail to reject the null hypothesis. There is insufficient evidence to conclude that the distributions differ.
For a normality test, rejecting the null hypothesis means that the sample provides evidence of a departure from normality. However, for a two-sample test, rejecting the null hypothesis means that the two population distributions differ significantly.
Keep in mind that a non-significant result does not prove that the distributions are identical. It only means that the test did not detect sufficient evidence of a difference.
Kolmogorov-Smirnov Test vs. Shapiro-Wilk Test
The Kolmogorov-Smirnov and Shapiro-Wilk tests can both be used to assess whether a sample comes from a normally distributed population. However, the two tests work differently.
The Kolmogorov-Smirnov test compares the empirical cumulative distribution of the sample with a specified theoretical distribution. When the normal distribution parameters are estimated from the sample, the Lilliefors correction is needed for the usual normality test. On the other hand, the Shapiro-Wilk test examines how closely the ordered observations follow the pattern expected from a normal distribution.
The Shapiro-Wilk test generally has greater statistical power for detecting departures from normality and is often preferred when the main objective is to check normality.
You can use the Shapiro-Wilk Test Calculator when you specifically want to test whether a sample follows a normal distribution.
However, if you want to compare two independent samples or test a sample against a fully specified normal, uniform, or exponential distribution, the Kolmogorov–Smirnov test is more appropriate.
Note. The Kolmogorov-Smirnov test is not automatically preferable when the sample size exceeds 50 observations. The choice depends on what you want to test and the characteristics of your data.
Frequently Asked Questions
A Kolmogorov-Smirnov test calculator is an online statistical tool used to compare a sample with a specified continuous distribution or determine whether two independent samples come from the same population distribution. This calculator provides the D statistic, p-value, hypothesis decision, and APA-style report.
The ordinary one-sample K-S test assumes that the reference distribution parameters are specified independently of the sample. The Lilliefors test adjusts the normality-test p-value when the mean and standard deviation are estimated from the same observations.
Yes. The Kolmogorov-Smirnov test can be used with small or large samples, provided the appropriate assumptions are satisfied. There is no general rule requiring at least 50 observations. However, very small samples may have limited power to detect differences.
The standard two-sample Kolmogorov-Smirnov test compares two independent groups at a time. If you have more than two groups, you can perform pairwise comparisons, but you should account for multiple testing when interpreting the results.
No. You need the individual observations to calculate the empirical cumulative distribution. The mean and standard deviation alone are not sufficient to calculate the K-S statistic.
No. A significant two-sample K-S test indicates that the population distributions differ. The difference may involve their location, spread, shape, or a combination of these characteristics. It does not specifically test the difference between population means.
