MCPcopy Create free account
hub / github.com/breck7/scroll / quantileIndex

Function quantileIndex

external/.d3.js:982–994  ·  view source on GitHub ↗
(values, p, valueof = number$3)

Source from the content-addressed store, hash-verified

980}
981
982function quantileIndex(values, p, valueof = number$3) {
983 if (isNaN(p = +p)) return;
984 numbers = Float64Array.from(values, (_, i) => number$3(valueof(values[i], i, values)));
985 if (p <= 0) return minIndex(numbers);
986 if (p >= 1) return maxIndex(numbers);
987 var numbers,
988 index = Uint32Array.from(values, (_, i) => i),
989 j = numbers.length - 1,
990 i = Math.floor(j * p);
991 quickselect(index, i, 0, j, (i, j) => ascendingDefined(numbers[i], numbers[j]));
992 i = greatest(index.subarray(0, i + 1), (i) => numbers[i]);
993 return i >= 0 ? i : -1;
994}
995
996function thresholdFreedmanDiaconis(values, min, max) {
997 const c = count$1(values), d = quantile$1(values, 0.75) - quantile$1(values, 0.25);

Callers 1

medianIndexFunction · 0.85

Calls 7

number$3Function · 0.85
minIndexFunction · 0.85
maxIndexFunction · 0.85
quickselectFunction · 0.85
ascendingDefinedFunction · 0.85
greatestFunction · 0.85
fromMethod · 0.45

Tested by

no test coverage detected