Package Exports
- stats-analysis
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (stats-analysis) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Statistics and Data Analysis
Mini javascript statistics library for nodejs or the browser.
No production dependencies.
Current Library Coverage
- Standard Deviation
- Mean
- Median
- Median Absolute Deviation (MAD)
- Outlier Detection (using Iglewicz and Hoaglin's method)
- Outlier Filter / Removal
- More?
Installation
$ npm install stats-analysis
Usage
var stats = require("./stats") // include statistics library
var arr = [-2, 1, 2, 2, 3, 3, 4, 15];
//standard deviation
stats.stdev(arr).toFixed(2) * 1 // Round to 2dp and convert to number
> 4.88
//mean
stats.mean(arr).toFixed(2) * 1
> 3.86
//median
stats.median(arr)
> 3
//median absolute deviation
stats.MAD(arr)
> 1
// outlier detection. Values above threshold are potential outliers
// 3 params: value-to-test, array, threshold = 3.5
stats.isOutlier(-10, arr) // Default theshold of 3.5 used
> true
stats.isOutlier(-3, arr, 5) // Pass higher threshold
> false
// filter outliers.
// 2 params: array, threshold = 3.5
stats.filterOutliers(arr) // Default threshold of 3.5 used
> [1, 2, 2, 3, 3, 4]
stats.filterOutliers(arr, 2.5) // Pass lower threshold
> [-2, 1, 2, 2, 3, 3, 4]
Tests
Mocha is used as the testing framework.
To run the tests, simply run the following commands:
$ npm install // Grab mocha
$ npm test // Run tests
Resources
Engineering statistics handbook:
http://www.itl.nist.gov/div898/handbook/index.htm
Contribute to the library
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -m 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
License
MIT