1
$\begingroup$

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$?

$\endgroup$

1 Answer 1

0
$\begingroup$

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$.

$\endgroup$
3
  • $\begingroup$ 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$? $\endgroup$
    – user36265
    Feb 1, 2014 at 19:52
  • $\begingroup$ 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. $\endgroup$
    – learner
    Feb 2, 2014 at 15:05
  • $\begingroup$ But why do you want to standardize your data, in the context of using the KS test? $\endgroup$
    – learner
    Feb 2, 2014 at 15:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.