# Interpretation and usage of Kolmogorov-Smirnov Test in Python

I have a sample of data, and I want to know weather it is Gaussian-distributed or not. The mean of my data is not zero.

To check weather I'm using the K-S test correct, I generated some Gaussian-distributed data and added some bias:

data = stats.norm.rvs(size=10000) + 1
print stats.kstest(data, 'norm')


This gives a p-value of 0.0. If I subtract the bias, I get something like 0.7-0.8, depending on the seed, of course. Does the data need to have $\mu = 0$? If so, does $\sigma^2 = 1$? What if my distribution has a different, unknown $\sigma^2$?

According to this SO question and the docs, it seems that the Python KS test default reference distribution is a normal distribution with $\mu = 0$ and $\sigma = 1$ ($N(0,1)$). See the SO question for more instructions on how to change the reference distribution.
In answer to your more specific question, you were using it correctly. In your first analysis, you had $p \approx 0.7$ when comparing 2 distributions which were $N(0,1)$. You then added 1 to all the terms in one distribution, so that the means were different, and $p = 0$.
• I'm sorry to bother you again, but i really don't understand how i have to renorm my data in order to get $\mu = 0$ and $\sigma = 1$. For the $\mu$ its easy, but how to do it for the $\sigma$? Feb 1, 2014 at 19:52
• So, the general approach is subtract the mean and divide by the standard deviation; that is, $x_{new} = \frac{x - \mu}{\sigma}$. You can use the code in this SO answer to standardize your data. Feb 2, 2014 at 15:05