1.0.0 • Published 6 years ago

atlas-mad v1.0.0

Weekly downloads
2
License
Apache-2.0
Repository
github
Last release
6 years ago

atlas-mad

Calculates the median absolute deviation of a set of data points in-place.

Travis


install

npm install --save atlas-mad

why

Breaking up atlas-dataset into standalone functions. This module computes the median absolute deviation (MAD) over an array of numbers:

The MAD is a more robust measure of "spread" in a distribution because it does not suffer from quadratic outlier contributions, unlike the standard deviation. The MAD is useful for cases where your data contains a small number of outliers (e.g. programming benchmarks).

examples

unsorted array

The mad function sorts the array in-place before calculating the median absolute deviation.

const mad = require("atlas-mad")
console.log(mad([4,3,1,2]))
// 1

sorted array

To avoid sorting a pre-sorted array, use a boolean flag:

...
const isSorted = true;
console.log(mad([1,2,3,4,5], isSorted)) // fast
// 1