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

interquartile_range.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 quantile from "./quantile";
/** * The [Interquartile range](http://en.wikipedia.org/wiki/Interquartile_range) is * a measure of statistical dispersion, or how scattered, spread, or * concentrated a distribution is. It's computed as the difference between * the third quartile and first quartile. * * @param {Array<number>} x sample of one or more numbers * @returns {number} interquartile range: the span between lower and upper quartile, * 0.25 and 0.75 * @example * interquartileRange([0, 1, 2, 3]); // => 2 */function interquartileRange(x) { // Interquartile range is the span between the upper quartile, // at `0.75`, and lower quartile, `0.25` const q1 = quantile(x, 0.75); const q2 = quantile(x, 0.25);
if (typeof q1 === "number" && typeof q2 === "number") { return q1 - q2; }}
export default interquartileRange;
simplestatistic

Version Info

Tagged at
2 years ago