MCPcopy Create free account
hub / github.com/breck7/scroll / quantile$1

Function quantile$1

external/.d3.js:957–968  ·  view source on GitHub ↗
(values, p, valueof)

Source from the content-addressed store, hash-verified

955}
956
957function quantile$1(values, p, valueof) {
958 values = Float64Array.from(numbers(values, valueof));
959 if (!(n = values.length) || isNaN(p = +p)) return;
960 if (p <= 0 || n < 2) return min$2(values);
961 if (p >= 1) return max$3(values);
962 var n,
963 i = (n - 1) * p,
964 i0 = Math.floor(i),
965 value0 = max$3(quickselect(values, i0).subarray(0, i0 + 1)),
966 value1 = min$2(values.subarray(i0 + 1));
967 return value0 + (value1 - value0) * (i - i0);
968}
969
970function quantileSorted(values, p, valueof = number$3) {
971 if (!(n = values.length) || isNaN(p = +p)) return;

Callers 3

medianFunction · 0.85
sequentialQuantileFunction · 0.85

Calls 5

numbersFunction · 0.85
min$2Function · 0.85
max$3Function · 0.85
quickselectFunction · 0.85
fromMethod · 0.45

Tested by

no test coverage detected