https://github.com/lemire/runningdog
Fast and accurate running statistics in Swift
https://github.com/lemire/runningdog
statistics swift
Last synced: over 1 year ago
JSON representation
Fast and accurate running statistics in Swift
- Host: GitHub
- URL: https://github.com/lemire/runningdog
- Owner: lemire
- License: apache-2.0
- Created: 2017-01-24T14:35:26.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-09-15T21:32:04.000Z (almost 9 years ago)
- Last Synced: 2025-01-16T03:14:31.394Z (over 1 year ago)
- Topics: statistics, swift
- Language: Swift
- Size: 6.84 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# RunningDog
Fast and accurate running statistics in Swift. This library can help
you keep track of the the standard deviation, variance and mean of
a set of a set of values.
Basic usage:
```swift
import RunningDog
var rd = RunningDog()
rd.add(1)
rd.add(2)
rd.add(3)
print(rd.mean)
print(rd.variance)
print(rd.maximum)
print(rd.minimum)
print(rd.standardDeviation)
```
## Complete example for library users
Create a directory where you will create your application:
```bash
mkdir fun
cd fun
swift package init --type executable
```
Then edit ``Package.swift`` so that it reads:
```swift
import PackageDescription
let package = Package(
name: "fun",
dependencies: [
.Package(url: "https://github.com/lemire/RunningDog.git", majorVersion: 0)
]
)
```
Edit ``Sources/main.swift`` so that it looks something like this :
```swift
import RunningDog
var rd = RunningDog()
rd.add(1)
rd.add(2)
rd.add(3)
print(rd.mean)
print(rd.variance)
print(rd.maximum)
print(rd.minimum)
print(rd.standardDeviation)
```
You can run your example as follows:
```bash
swift build -Xcc -march=native --configuration
.build/release/fun
```
## For Xcode users (Mac Only)
```bash
$ swift package generate-xcodeproj
generated: ./RunningDog.xcodeproj
$ open ./RunningDog.xcodeproj
```
## Licensing
Apache 2.0