-1 to the pitch and all code examples above that compute sum
and then divide by n
.
There are various statistics you might want to gather from a sequence of numbers: Mean, Variance, Standard Deviation, Skewness, Kurtosis…
The proposed addition of average
does not meet the high bar of
Have a look at the above quoted post to see what it takes to extend standard library.
The reduce
method from Sequence
protocol is fully sufficient for implementing these properly using the non-naive method in single pass.
@Nevin, would you mind sharing your Statistic
struct with the community?