JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 552
  • Score
    100M100P100Q99109F
  • License MIT

Engineering statistics and data analysis

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

Build Status codecov.io

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-analysis

Usage

var stats = require("./stats-analysis") // include statistics library
var 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 tests

Resources

Engineering statistics handbook:
http://www.itl.nist.gov/div898/handbook/index.htm

Contribute to the library

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -m 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

License

MIT