![]() |
|
#1
|
|||
|
|||
|
Bug in kstwo.cpp
The lines
if ((d1=data1[j1]) <= (d2=data2[j2])) fn1=j1++/en1; if (d2 <= d1) fn2=j2++/en2; should be if ((d1=data1[j1]) <= (d2=data2[j2])) fn1=++j1/en1; if (d2 <= d1) fn2=++j2/en2; (i.e., change j1++ to ++j1 and similarly for j2). This bug skips the contribution from the first data point (if any), so it is negligible for reasonably large data sets. But you would definitely notice it on small test cases. This bug is present only in the C++ code, and only in v2.10 and v2.11. Thanks to Heng Sun for reporting this. |
|
#2
|
|||
|
|||
|
Fix is wrong
Because we start with j=1, the correct code is j++ instead of ++j. If we start in j=0, then we use ++j.
This is due to the unit-offset of arrays' head pointer discussed in page 18 of the version 2 of the book. I confirmed my results with Matlab and other KS-Test code. |
|
#3
|
|||
|
|||
|
Hi,
You are referring to the C routine, kstwo.c, which is indeed correct. This fix refers to the C++ version, kstwo.cpp, where arrays are zero-based. The bug has been fixed in the 3rd edition. Saul Teukolsky |
![]() |
| Thread Tools | |
| Display Modes | |
|
|