Statistics: Kolmogorov–Smirnov test

This is part of the course “Probability Theory and Statistics for Programmers”.

Image for post
Image for post
Probability Theory and Statistics For Programmers

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.

Image for post
Image for post
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.

Image for post
Image for post

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

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

Image for post
Image for post
Kolmogorov distribution

The tricky part is to get critical value for the specified significance level from this distribution. Therefore, I will take the critical value for the significance level of 0.05 and a sample size of 80 from the table, it equal to 0.152. The null hypothesis is rejected if:

Image for post
Image for post
condition of rejection

Next part ->

Reach the next level of focus and productivity with increaser.org.

Image for post
Image for post
Increaser

Written by

Software engineer, creator of increaser.org. More at geekrodion.com

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store