KS-Test and its significance

Thiruthuvaraj Rajasekhar
2 min readMar 12, 2022

We would have seen, Z-Test, t-test etc, that presumes that the distribution should be a Normal Distribution. Have we ever wondered, is there a test to tell if a if a particular sample is coming from a certain distribution. Kolomogrov-Smrinov Test or KS-Test comes to our rescue to clear this doubt.

Kolomogrov-Smrinov Test or KS-Test in short is a statistical test used to check the if a particular sample is coming from a certain distribution.

Suppose we have observations x1, x2, …xn that we think come from a distribution D. The KS test is used to evaluate:

  • Null Hypothesis: The samples come from D
  • Alternative Hypothesis: The samples do not come from D

We compare the cdf and edf of sample and compare them. If the difference is below a critical value, we say they are from same distribution. Following are the steps used for testing using KS-Test.

  • Sort the observations in ascending order
  • Calculate the EDF of sorted observations
  • Calculate the CDF of observations
  • Compute the absolute differences
  • Record the maximum difference
  • Calculate the critical value
  • Reject or accept null hypothesis

EDF — Emprical Distribution Function of a series is calculated as shown below:

For a series of 17,21,23 etc., emperical df is computed as 1/12, 2/12,3/12 etc.,

We compare this EDF with CDF of X1 series by taking an absolute difference as below. We assume that X1 is from normal distribution with mean, 36.25 and std_dev 12.09151.

We take the maximum absolute difference between the values (0.58998)and to determine if this maximum value is statistically significant, we must refer to a Kolmogorov-Smirnov Table of critical values and find the number equal to n = 12 and α = .05.

The critical value turns out to be 0.3754.

Since our value 0.5899 > critical value, hence we reject the null hypothesis and we conclude that, the given series is not coming from Normal Distribution.

Support if you like this article and comment if you need more clarification!!! Thanks!!! 😊

--

--

Thiruthuvaraj Rajasekhar

Mining Data For Insights | Passionate to write | Data Scientist