Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/atlassubbed/atlas-mad
https://github.com/atlassubbed/atlas-mad
Last synced: 21 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/atlassubbed/atlas-mad
- Owner: atlassubbed
- License: other
- Created: 2018-07-16T03:03:48.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-07-16T03:31:35.000Z (over 6 years ago)
- Last Synced: 2024-12-05T18:44:11.253Z (about 1 month ago)
- Language: JavaScript
- Size: 7.81 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# atlas-mad
Calculates the median absolute deviation of a set of data points in-place.
[![Travis](https://img.shields.io/travis/atlassubbed/atlas-mad.svg)](https://travis-ci.org/atlassubbed/atlas-mad)
---
## install
```
npm install --save atlas-mad
```## why
Breaking up [atlas-dataset](https://github.com/atlassubbed/atlas-dataset#readme) 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.
```javascript
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:
```javascript
...
const isSorted = true;
console.log(mad([1,2,3,4,5], isSorted)) // fast
// 1
```