I'm a bit confused about the way handles the Kolmogorov-Smirnov test for comparing two distributions. From what I know about the K-S test, the test statistic is the maximum difference between the CDFs of the two distributions (i.e., max|F(x) - F(y)|).

In the data below, x is the CDF of the first variable and y is the CDF of the second variable for a certain value. Cumdiff is the difference between the two CDFs at that value, and the maximum cumdiff = 0.1537. That is, D=max|F(x) - F(y)| = 0.1537 and that is, as far as I understand, the value of the K-S test statistic.

x y cumdiff

0.03703704 0.1569463 0.1199

0.51851852 0.4475875 0.0709

0.87037037 0.7166997 0.1537

0.92592593 0.8828184 0.0431

0.96296296 0.9597252 0.0032

0.98148148 0.9999754 0.0185

1.00000000 0.9999959 0.0000

However, when I run the command ks.test(x,y), I get the following:

data: x and y

D = 0.14286, p-value = 1

alternative hypothesis: two-sided.

My question: why is D in the output 0.14286 and not 0.1537?

Thank you!