Skip to content

KS test and theoretical distribution

3 messages · francogrex, Achim Zeileis, Brian Ripley

#
Two-sample Kolmogorov-Smirnov test

data:  x and y 
D = 0.11, p-value = 0.5806
alternative hypothesis: two-sided 

ok I expected that, but:
One-sample Kolmogorov-Smirnov test

data:  runif(100) 
D = 0.9106, p-value < 2.2e-16
alternative hypothesis: two-sided 

How come? 

--
View this message in context: http://r.789695.n4.nabble.com/KS-test-and-theoretical-distribution-tp3878640p3878640.html
Sent from the R help mailing list archive at Nabble.com.
#
On Thu, 6 Oct 2011, francogrex wrote:

            
Because you didn't read the docs, or didn't follow them, or mistyped. The 
docs say

        y: either a numeric vector of data values, or a character string
           naming a cumulative distribution function or an actual
           cumulative distribution function such as 'pnorm'.  Only
           continuous CDFs are valid.

So you would want

ks.test(runif(100), "punif")

Best,
Z
#
On Thu, 6 Oct 2011, francogrex wrote:

            
Pilot error.  The help says

        y: either a numeric vector of data values, or a character string
           naming a cumulative distribution function or an actual
           cumulative distribution function such as ?pnorm?.  Only
           continuous CDFs are valid.

"runif" is not 'an actual cumulative distribution function' ....