MCPcopy Create free account
hub / github.com/d3/d3-array / quantileSorted

Function quantileSorted

src/quantile.js:23–33  ·  view source on GitHub ↗
(values, p, valueof = number)

Source from the content-addressed store, hash-verified

21}
22
23export function quantileSorted(values, p, valueof = number) {
24 if (!(n = values.length) || isNaN(p = +p)) return;
25 if (p <= 0 || n < 2) return +valueof(values[0], 0, values);
26 if (p >= 1) return +valueof(values[n - 1], n - 1, values);
27 var n,
28 i = (n - 1) * p,
29 i0 = Math.floor(i),
30 value0 = +valueof(values[i0], i0, values),
31 value1 = +valueof(values[i0 + 1], i0 + 1, values);
32 return value0 + (value1 - value0) * (i - i0);
33}
34
35export function quantileIndex(values, p, valueof = number) {
36 if (isNaN(p = +p)) return;

Callers 1

quantile-test.jsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…