R: Is the Kolmogorov–Smirnov test capable of comparing samples?
Does anyone know whether the Kolmogorov–Smirnov test is capable of comparing samples?
According to the definition of the Kolmogorov–Smirnov test, it is a nonparametric test for the equality of continuous, one-dimensional probability distributions that can be used to compare a sample with a reference probability distribution (one-sample K–S test), or to compare two samples.
Does anyone know if the code in R is able to comp开发者_Go百科are samples and is not just limited to comparison to a theoretical distribution? And if so, could you please give an example?
Examples are to be found in the help files of ks.test. (?ks.test
) :
Usage
ks.test(x, y, ...,
alternative = c("two.sided", "less", "greater"),
exact = NULL)
Arguments
x a numeric vector of data values.
y either a numeric vector of data values, or a character string naming a ...
Tells you how to do it, and :
Examples
require(graphics)
x <- rnorm(50)
y <- runif(30)
# Do x and y come from the same distribution?
ks.test(x, y)
is the first example in the help files. Please read them before asking. They're there for a reason, and that reason is not "entertainment of the R-development team".
精彩评论