# Add average to FloatingPoint arrays

**URL:** <https://forums.swift.org/t/add-average-to-floatingpoint-arrays/11428>\
**Category:** Pitches\
**Created:** [March 27, 2018, 2:59pm UTC](https://forums.swift.org/t/add-average-to-floatingpoint-arrays/11428 "2018-03-27T14:59:52Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![palimondo](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/palimondo/32/1144_2.png) [@palimondo](https://forums.swift.org/u/palimondo)\
**Post date:** [March 27, 2018, 10:08pm UTC](https://forums.swift.org/t/add-average-to-floatingpoint-arrays/11428/7 "2018-03-27T22:08:54Z")

</div>

-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](https://www.johndcook.com/blog/skewness_kurtosis/)…  
The proposed addition of `average` does not meet the high bar of

> [@\`count(where:)\` on Sequence](https://forums.swift.org/t/count-where-on-sequence/11186/22):
>
> criteria […] for justifying addition to the standard library

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?

---

_[View the full topic](https://forums.swift.org/t/add-average-to-floatingpoint-arrays/11428)._
