I created a sample with 10000 normally distributed numbers. Subsequently, I used the Kolmogorov-Smirnov test to check if they are indeed normally distributed, and it turned out that they are not. How is this possible?
Below is my code.
data <- rnorm(n=10000, 5, 2)
ks.test(data, "pnorm")
And this is the answer:
Exact one-sample Kolmogorov-Smirnov test
data: data D = 1, p-value < 2.2e-16 alternative hypothesis: two-sided
rnorm
in your code drawing from? What distribution ispnorm
defining? $\endgroup$rnorm
generates 1000 normally distributed numbers. Then, I am trying to see if they follow the normal distribution (pnorm
). Therefore, the null hypothesis should not be rejected. $\endgroup$set.seed()
to make the random values reproducible. But to the point: If not specified,ks.test
will test against a standard normal. So you should useks.test(data, "pnorm", 5, 2)
. But please remember that the KS-test assumes the parameters to be known a priori and not estimated from the data. Also pay close attention to what utobi said. Finally, no normality test can confirm that your sample is normally distributed. Non-significance does not mean "normally distributed". $\endgroup$