[SciPy-User] ks_2samp is not giving the same results as ks.test in R

Peng Yu pengyu.ut@gmail....
Thu Nov 1 19:28:47 CDT 2012


Hi,

The ks_2samp function does not give the same answer as ks.test in R.
Does anybody know why they are different? Is ks_2samp compute
something different?

helium:~/linux/test/python/man/library/scipy/stats/ks_2samp$ Rscript main.R
> ks.test(1:5, 11:15)

        Two-sample Kolmogorov-Smirnov test

data:  1:5 and 11:15
D = 1, p-value = 0.007937
alternative hypothesis: two-sided

> ks.test(1:5, 11:15, alternative='less')

        Two-sample Kolmogorov-Smirnov test

data:  1:5 and 11:15
D^- = 0, p-value = 1
alternative hypothesis: the CDF of x lies below that of y

> ks.test(1:5, 11:15, alternative='greater')

        Two-sample Kolmogorov-Smirnov test

data:  1:5 and 11:15
D^+ = 1, p-value = 0.006738
alternative hypothesis: the CDF of x lies above that of y

>
>
helium:~/linux/test/python/man/library/scipy/stats/ks_2samp$ ./main.py
(1.0, 0.0037813540593701006)
helium:~/linux/test/python/man/library/scipy/stats/ks_2samp$ cat main.py
#!/usr/bin/env python

from scipy.stats import ks_2samp
print ks_2samp([1,2,3,4,5], [11,12,13,14,15])


-- 
Regards,
Peng


More information about the SciPy-User mailing list