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

Function quantileSorted

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

Source from the content-addressed store, hash-verified

968}
969
970function quantileSorted(values, p, valueof = number$3) {
971 if (!(n = values.length) || isNaN(p = +p)) return;
972 if (p <= 0 || n < 2) return +valueof(values[0], 0, values);
973 if (p >= 1) return +valueof(values[n - 1], n - 1, values);
974 var n,
975 i = (n - 1) * p,
976 i0 = Math.floor(i),
977 value0 = +valueof(values[i0], i0, values),
978 value1 = +valueof(values[i0 + 1], i0 + 1, values);
979 return value0 + (value1 - value0) * (i - i0);
980}
981
982function quantileIndex(values, p, valueof = number$3) {
983 if (isNaN(p = +p)) return;

Callers 1

rescaleFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected