Details
-
Improvement
-
Status: Closed
-
Trivial
-
Resolution: Implemented
-
None
-
None
-
Easy
Description
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.