I'd like to check if distribution of my data is significantly different from a uniform distribution. I know that the K-S test is used for checking the normality of data, but I wonder if it can be applied also to check the uniformity of data as well?
-
1$\begingroup$ A quantile-quantile plot for a uniform distribution should show a straight line, so should always be drawn, regardless of any desire for a significance test. $\endgroup$– Nick CoxCommented Mar 6, 2015 at 9:49
-
$\begingroup$ Others here can read, write and speak Russian, and I don't, but it's my understanding that the two surnames here really do end with the same letter, so should be transliterated in exactly the same way. I recollect seeing the -ff ending more frequently when I was younger, but regardless of that Kolmogorov-Smirnov now seems a universal convention in statistical literature in English. $\endgroup$– Nick CoxCommented Mar 6, 2015 at 10:08
-
$\begingroup$ To add to @NickCox's point, the spelling 'Smirnoff' always reminds me of liquor. $\endgroup$– Marc ClaesenCommented Mar 6, 2015 at 14:27
-
$\begingroup$ I've made occasional weak jokes exploiting this. You can try it yourself: "This procedure has a flavour of Kolmogorov-Smirnov, but the flavour is more Smirnov than Kolmogorov". Even with a technically knowledgeable audience, it has to make sense in context. $\endgroup$– Nick CoxCommented Mar 6, 2015 at 14:43
1 Answer
The Kolmogorov-Smirnov test can be used to test with a null of any fully specified continuous distribution.
Since the statistic is only a function of the largest difference in cdf, if you use a probability integral transform on the data, that won't change the test statistic but turns it into a test against uniformity.
The top plot shows the situation in a test for normality, the bottom plot shows a test for standard uniform on transformed data. The distance, (D, marked in blue) is the same given any monotonic transformation of the x-axis.
So every KS test will be exactly the same as if you were doing a test of uniformity -- i.e. it's distribution-free -- as long as the distribution is continuous and fully specified (no parameters to estimate), it doesn't matter what the distribution is, the test works exactly the same.
So uniform, normal, gamma, beta, Cauchy, logistic, Student t, or whatever else you like.
(If the distribution is not fully specified - i.e. if you don't know one or more parameters, then it's not actually a Kolmogorov-Smirnov test, but a Lilliefors test*, and no longer distribution free, though in the case of uniformity there's a neat trick which could be used to take it back to a fully specified distribution.)
* Lilliefors himself did the normal and exponential cases
--
In respect of your title, there's nothing that will tell you your data are from a uniformly distributed population -- but a goodness of fit test may tell you that they aren't.