Displaying 1 result from an estimated 1 matches for "ks_2samp".
2023 Mar 01
1
Incorrect behavior of ks.test and psmirnov functions with exact=TRUE
...ower.tail = F,
exact=TRUE)
produces 2.775558e-15
However, the exact value should be 1/combination(100, 50), which is
9.9e-30. While the absolute error is small, the relative error is huge, and
it is not fixed by setting option log.p=T
To compare, SciPy has a correct implementation in scipy.stats.ks_2samp:
scipy.stats.ks_2samp(list(range(1,51)), list(range(51, 101)),
alternative="greater", method="exact")
returns 9.911653021418333e-30.
I've tried to dig in a bit and the problem comes down to how the final
value is calculated in psmirnov function:
if (log.p & !lower....