hotime/vendor/github.com/montanaflynn/stats
2022-10-19 21:32:34 +08:00
..
.gitignore 升级流程引擎配置文件版本 2022-10-19 21:32:34 +08:00
.travis.yml 升级流程引擎配置文件版本 2022-10-19 21:32:34 +08:00
CHANGELOG.md 升级流程引擎配置文件版本 2022-10-19 21:32:34 +08:00
correlation.go 升级流程引擎配置文件版本 2022-10-19 21:32:34 +08:00
data_set_distances.go 升级流程引擎配置文件版本 2022-10-19 21:32:34 +08:00
data.go 升级流程引擎配置文件版本 2022-10-19 21:32:34 +08:00
deviation.go 升级流程引擎配置文件版本 2022-10-19 21:32:34 +08:00
errors.go 升级流程引擎配置文件版本 2022-10-19 21:32:34 +08:00
legacy.go 升级流程引擎配置文件版本 2022-10-19 21:32:34 +08:00
LICENSE 升级流程引擎配置文件版本 2022-10-19 21:32:34 +08:00
load.go 升级流程引擎配置文件版本 2022-10-19 21:32:34 +08:00
Makefile 升级流程引擎配置文件版本 2022-10-19 21:32:34 +08:00
max.go 升级流程引擎配置文件版本 2022-10-19 21:32:34 +08:00
mean.go 升级流程引擎配置文件版本 2022-10-19 21:32:34 +08:00
median.go 升级流程引擎配置文件版本 2022-10-19 21:32:34 +08:00
min.go 升级流程引擎配置文件版本 2022-10-19 21:32:34 +08:00
mode.go 升级流程引擎配置文件版本 2022-10-19 21:32:34 +08:00
outlier.go 升级流程引擎配置文件版本 2022-10-19 21:32:34 +08:00
percentile.go 升级流程引擎配置文件版本 2022-10-19 21:32:34 +08:00
quartile.go 升级流程引擎配置文件版本 2022-10-19 21:32:34 +08:00
README.md 升级流程引擎配置文件版本 2022-10-19 21:32:34 +08:00
regression.go 升级流程引擎配置文件版本 2022-10-19 21:32:34 +08:00
round.go 升级流程引擎配置文件版本 2022-10-19 21:32:34 +08:00
sample.go 升级流程引擎配置文件版本 2022-10-19 21:32:34 +08:00
sum.go 升级流程引擎配置文件版本 2022-10-19 21:32:34 +08:00
util.go 升级流程引擎配置文件版本 2022-10-19 21:32:34 +08:00
variance.go 升级流程引擎配置文件版本 2022-10-19 21:32:34 +08:00

Stats

A statistics package with many functions missing from the Golang standard library. See the CHANGELOG.md for API changes and tagged releases you can vendor into your projects.

Statistics are used much like a drunk uses a lamppost: for support, not illumination. - Vin Scully

Installation

go get github.com/montanaflynn/stats

Protip: go get -u github.com/montanaflynn/stats updates stats to the latest version.

Usage

The entire API documentation is available on GoDoc.org

You can view docs offline with the following commands:

godoc ./
godoc ./ Median
godoc ./ Float64Data

Protip: Generate HTML docs with godoc -http=:4444

Example

All the functions can be seen in examples/main.go but here's a little taste:

// start with the some source data to use
var data = []float64{1, 2, 3, 4, 4, 5}

median, _ := stats.Median(data)
fmt.Println(median) // 3.5

roundedMedian, _ := stats.Round(median, 0)
fmt.Println(roundedMedian) // 4

Protip: You can call methods on the data if using the Float64Data type:

var d stats.Float64Data = data

max, _ := d.Max()
fmt.Println(max) // 5

Contributing

If you have any suggestions, criticism or bug reports please create an issue and I'll do my best to accommodate you. In addition simply starring the repo would show your support for the project and be very much appreciated!

Pull Requests

Pull request are always welcome no matter how big or small. Here's an easy way to do it:

  1. Fork it and clone your fork
  2. Create new branch (git checkout -b some-thing)
  3. Make the desired changes
  4. Ensure tests pass (go test -cover or make test)
  5. Commit changes (git commit -am 'Did something')
  6. Push branch (git push origin some-thing)
  7. Submit pull request

To make things as seamless as possible please also consider the following steps:

  • Update README.md to include new public types or functions in the documentation section.
  • Update examples/main.go with a simple example of the new feature.
  • Keep 100% code coverage (you can check with make coverage).
  • Run gometalinter and make your code pass.
  • Squash needless commits into single units of work with git rebase -i new-feature.

Makefile

I've included a Makefile that has a lot of helper targets for common actions such as linting, testing, code coverage reporting and more.

Protip: watch -n 1 make check will continuously format and test your code.

MIT License

Copyright (c) 2014-2015 Montana Flynn http://anonfunction.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORpublicS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.