insaf021 opened a new pull request, #357:
URL: https://github.com/apache/commons-math/pull/357

   On master:
   
       KendallsCorrelationTest.testSignedZeroTies: 
expected:<0.8164965809277261> but was:<0.3333333333333333>
   
       correlation({0.0, -0.0, 1.0}, {1, 2, 3})  = 0.3333  (tau-b: 2/sqrt(6) = 
0.8165)
       correlation({0.0, -0.0}, {1, 2})          = -1.0    (all x tied: NaN)
   
   `KendallsCorrelation.correlation` boxes the inputs into `Pair<Double, 
Double>` and finds ties with `Double.equals` and orders with 
`Double.compareTo`. Both treat `-0.0` and `0.0` as different values, so a pair 
whose x (or y) values are the two zeros is scored as concordant or discordant 
rather than tied, and the tau-b denominator loses that tie as well. Signed 
zeros turn up from ordinary arithmetic on the data (negation, products, small 
negatives rounded to zero), and the other correlations in the package treat 
them as equal.
   
   The values are now normalised with `+ 0.0` when the pairs are built, which 
maps `-0.0` to `0.0` and leaves every other double, including NaN, unchanged. 
The sort, the merge-sort swap count and the tie scans then all see one zero.
   
   `testSignedZeroTies` covers ties in x, ties in y and the all-tied case; it 
fails on master as above and passes with the patch. `mvn clean verify 
javadoc:javadoc -pl commons-math-legacy` is green on JDK 21 (3273 tests, 0 
Checkstyle violations).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to