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 (sorts before calculating)
- Median Absolute Deviation (MAD)
- Outlier Detection & Filtering using Iglewicz and Hoaglin's method (MAD)
- Outlier Detection & Filtering using Median Differencing (Default method)
Installation
$ npm install stats-analysisUsage
var stats = require("./stats-analysis") // include statistics libraryvar arr = [-2, 1, 2, 3, 3, 4, 15]
//standard deviation
stats.stdev(arr).toFixed(2) * 1 // Round to 2dp and convert to number
> 4.98
//mean
stats.mean(arr).toFixed(2) * 1
> 3.57
//median
stats.median(arr)
> 2
//median absolute deviation
stats.MAD(arr)
> 1
// Outlier detection. Returns indexes of outliers
stats.indexOfOutliers(arr) // Default theshold of 3
> [6]
stats.indexOfOutliers(arr, 6) // Supply higher threshold to allow more outliers.
// Outlier filtering. Returns array with outliers removed.
stats.filterOutliers(arr)
> [-2, 1, 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 testsResources
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
