deno.land / x / simplestatistic@v7.7.1 / src / median_absolute_deviation.js

median_absolute_deviation.js
نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import median from "./median";
/** * The [Median Absolute Deviation](http://en.wikipedia.org/wiki/Median_absolute_deviation) is * a robust measure of statistical * dispersion. It is more resilient to outliers than the standard deviation. * * @param {Array<number>} x input array * @returns {number} median absolute deviation * @example * medianAbsoluteDeviation([1, 1, 2, 2, 4, 6, 9]); // => 1 */function medianAbsoluteDeviation(x) { const medianValue = median(x); const medianAbsoluteDeviations = [];
// Make a list of absolute deviations from the median for (let i = 0; i < x.length; i++) { medianAbsoluteDeviations.push(Math.abs(x[i] - medianValue)); }
// Find the median value of that list return median(medianAbsoluteDeviations);}
export default medianAbsoluteDeviation;
simplestatistic

Version Info

Tagged at
2 years ago