[
https://issues.apache.org/jira/browse/STATISTICS-84?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17803509#comment-17803509
]
Alex Herbert commented on STATISTICS-84:
----------------------------------------
Performance when updated to use a Sum:
||length||name||Score||
|1|Mean|9.0|
|1|SumMean|3.9|
|1|ExtendedSumMean|4.4|
|10|Mean|17.1|
|10|SumMean|5.6|
|10|ExtendedSumMean|8.4|
|1000|Mean|1873.7|
|1000|SumMean|783.3|
|1000|ExtendedSumMean|1009.7|
Note that the Mean is still using a second pass over the data to perform a
correction to the initial mean. On the current test suite this correction
typically makes the mean less accurate (by a few ULP). Note that the test data
consists mainly of integer values or floating-point values with 1 digit after
the decimal point so these are floating-point sums with little loss of
precision.
Use of the second pass to correct the initial mean should be investigated using
data with different condition number. The condition number of a sum is the sum
of the absolute values divided by the absolute sum of values:
{noformat}
sum(|x|) / |sum(x)|{noformat}
The condition number represents the intrinsic sensitivity of the summation
problem to errors regardless of how it is computed.
> Create the Mean from array input using a summation
> --------------------------------------------------
>
> Key: STATISTICS-84
> URL: https://issues.apache.org/jira/browse/STATISTICS-84
> Project: Commons Statistics
> Issue Type: Improvement
> Components: descriptive
> Reporter: Alex Herbert
> Priority: Trivial
>
> The creation of the Mean from an array uses the rolling mean algorithm. This
> requires a divide for each input value. The algorithm is slow when compared
> to a simple sum of the values and a divide of the sum. The advantage is that
> the algorithm is overflow safe and computes the mean in a single pass (useful
> for streams).
> In the majority of use cases a sum will not overflow. Change the array
> construction to attempt a sum to compute the mean, reverting to the rolling
> mean if this fails.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)