Miss any of our Open RFC calls?Watch the recordings here! »

atlas-mad

1.0.0 • Public • Published

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:

mad(V) = median(|v_i - median(V)|)

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

Install

npm i atlas-mad

DownloadsWeekly Downloads

2

Version

1.0.0

License

Apache-2.0

Unpacked Size

3.85 kB

Total Files

6

Last publish

Collaborators

  • avatar