Repository navigation
Conversation
correlation boxes the values into Pair<Double, Double> and detects ties
with Double.equals and orders them with Double.compareTo, which both
treat -0.0 and 0.0 as different values. A pair whose x or y values are
0.0 and -0.0 was counted as concordant or discordant instead of tied, so
correlation({0.0, -0.0, 1.0}, {1, 2, 3}) returned 1/3 instead of
2/sqrt(6).
Map -0.0 to 0.0 when the pairs are built.
Contributor
|
Discussion issue: https://issues.apache.org/jira/browse/MATH-1698 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On master:
KendallsCorrelation.correlationboxes the inputs intoPair<Double, Double>and finds ties withDouble.equalsand orders withDouble.compareTo. Both treat-0.0and0.0as 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.0when the pairs are built, which maps-0.0to0.0and leaves every other double, including NaN, unchanged. The sort, the merge-sort swap count and the tie scans then all see one zero.testSignedZeroTiescovers 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-legacyis green on JDK 21 (3273 tests, 0 Checkstyle violations).