This question already has an answer here:
I'm trying to understand the Kolmogorov-Smirnov test using a very simple example. I generate a set of random, uniform values between 0 and 1.0. I then test that these values are from a uniform distribution by using the scipy kstest function. I'm expecing a very small D value and a pvalue close to 1.0, but instead I get wildly varying pvalues every time I run the code. What am I missing?
import numpy as np import scipy a = np.random.uniform(size=4999) print(scipy.stats.kstest(a, 'uniform'))
Here are the outputs of a few consecutive runs:
(0.0075523161200627964, 0.93798952050647577) (0.013787195268362473, 0.29799260741344774) (0.014359046616557847, 0.25402403230845855) (0.012521820948675988, 0.41329007558099806) (0.011159003477582918, 0.56216895575676396)