# Kolmogorov–Smirnov Test with Python

May 26, 2018 Previously we have seen tests that can be used only with normally distributed data. But what if we don’t have normality assumptions about the data? In this article, we will cover one of the most popular among nonparametric tests — the Kolmogorov-Smirnov test(K-S test).

## Statistic

At first, let’s introduce a statistic of K-S test.

It means we go through each point of the empirical distribution function of our sample and calculate the absolute difference between it and a corresponding value of population distribution function. The maximum of those differences is the value of the statistic.

Now let’s make a simulation. Exists gamma-distributed population and we have a sample from it. What is the K-S statistic?

Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

## Kolmogorov distribution function

As you may remember from the previous article, we use appropriated distribution to get critical value. Then we can make a conclusion. The Kolmogorov distribution it is the tricky one, but anyway :) The Kolmogorov distribution is the distribution of the random variable, where B(t) is the Brownian bridge