natalia-io / SimpleStats

Calculate statistics quickly and easily on Swift.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SimpleStats

CI Status Version License Platform

Example

Usage is very simple. After installation, write at the top of your file:

import SimpleStats

From then on, you can call functions such as .avg(), .sd(), .variance(), etc. on arrays of type [Double] and [Int], like so:

var xValues:[Double] = [7.5,8.8,9.3,8.1,6,8,7,5.9,2.3,7]
var yValues:[Double] = [203,345,174,245,235,864,356,668,847,905]
print(xValues.avg())
print(yValues.avg())
//6.99
//484.2

Create a dictionary from two arrays with the same count and you can easily calculate correlation:

var dictionary = [Double:Double]()

for i in xValues.indices {
    dictionary[xValues[i]] = yValues[i]
}

var correlation = dictionary.r()
print(correlation)

//-0.4980879419156199

Requirements

Installation

SimpleStats is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'SimpleStats'

Author

Natália Mendonça, natalia@smartmood.io

License

SimpleStats is available under the MIT license. See the LICENSE file for more info.

About

Calculate statistics quickly and easily on Swift.

License:MIT License


Languages

Language:Swift 90.1%Language:Ruby 9.9%