[swift-users] Implementing a few statistics functions in Swift

Georgios Moschovitis george.moschovitis at icloud.com
Sat Oct 8 13:29:33 CDT 2016


Hey everyone,

I would like to implement a few statistics functions in Swift (e.g. variance, standardDeviation, etc) that are computed over a collection.

I am aware of this library:

https://github.com/evgenyneu/SigmaSwiftStatistics <https://github.com/evgenyneu/SigmaSwiftStatistics>

My problem is that it only supports Doubles and Arrays. Also the API doesn’t look very ‘swifty' to me.

I am wondering how would someone implement such functionality in a more generic way: to allow usage of multiple collections (even custom, e.g. a RingBuffer) and multiple value types (e.g. Decimal, Double). Extra points for being 'swifty'.

Thanks in advance for any ideas.

-g.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20161008/2c7d7bdb/attachment.html>


More information about the swift-users mailing list