insaf021 opened a new pull request, #354:
URL: https://github.com/apache/commons-math/pull/354
On master, with `SummaryStatistics` partitions:
aggregate([{1, 2}, {3}]) n=3 min=1.0 max=3.0 mean=2.0 variance=1.0
sum=6.0
aggregate([{1, 2}, {}, {3}]) n=3 min=NaN max=NaN mean=NaN variance=NaN
sum=NaN
`SummaryStatistics` reports NaN for every statistic while it holds no
values, and `AggregateSummaryStatistics.aggregate` folds each summary in
unconditionally: `JdkMath.min`/`max` propagate the NaN, and the sum, mean and
second moment pick it up through the running totals. One empty partition
anywhere in the collection therefore wipes out the combined result, although
the javadoc says it should match a single summary over the combined data. Empty
partitions are routine when work is split across threads or groups. The
NaN-tolerant min/max removed in MATH-1671 masked part of this; the variance was
already lost before that.
Summaries with `getN() == 0` are now skipped, both when picking the starting
summary and in the accumulation loop, and the javadoc says so. An all-empty
collection still returns n = 0 with NaN statistics, as before.
`AggregateSummaryStatisticsTest.testAggregateEmptySummaries` puts empty
partitions at the start, middle and end. On master it fails with
`expected:<5.0> but was:<NaN>`; it passes with the patch. `mvn clean verify
javadoc:javadoc -pl commons-math-legacy -am` is green on JDK 21 (3264 tests in
legacy, Checkstyle and SpotBugs clean).
--
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]