Bill Press
04-29-2005, 09:47 AM
Charles Kankelborg has correctly noticed that the two-dimensional Kolmogorov tests ks2d1s and ks2d2s do not exactly agree with the original tests proposed by Fasano and Franceschini. The issue is, when you count points in quadrants around some point (x,y), which quadrant do you put (x,y) itself in? The current routines assign (x,y) arbitrarily to one quadrant. The original F&F algorithm assigns (x,y) to the quadrant where it would do the most good, i.e., where it will increase the maximum difference.
To fix this in ks2d1s, add lines like
if (fa > ga) fa += 1.0/n1;
if (fb > gb) fb += 1.0/n1;
if (fc > gc) fc += 1.0/n1;
if (fd > gd) fd += 1.0/n1;
inside the for-loop, just after the call to quadvl.
To fix it in ks2d2s, add the same lines as above in the first for-loop, and add corresponding lines exchanging the roles of "f" and "g" in the second for-loop.
In both cases, you must also make the following change in quadct: Insert a new line as the first line in the for-loop
if (yy[k] == y && xx[k] == x) continue;
The discrepancy is significant only when the number of points is small, but it is still evident at n=50. Metchev and Grindlay, Mon. Not. Roy. Astron. Soc. 335, 73-83, 2002, also noted the problem.
To fix this in ks2d1s, add lines like
if (fa > ga) fa += 1.0/n1;
if (fb > gb) fb += 1.0/n1;
if (fc > gc) fc += 1.0/n1;
if (fd > gd) fd += 1.0/n1;
inside the for-loop, just after the call to quadvl.
To fix it in ks2d2s, add the same lines as above in the first for-loop, and add corresponding lines exchanging the roles of "f" and "g" in the second for-loop.
In both cases, you must also make the following change in quadct: Insert a new line as the first line in the for-loop
if (yy[k] == y && xx[k] == x) continue;
The discrepancy is significant only when the number of points is small, but it is still evident at n=50. Metchev and Grindlay, Mon. Not. Roy. Astron. Soc. 335, 73-83, 2002, also noted the problem.