-
-
Notifications
You must be signed in to change notification settings - Fork 52
Incorrect quantile computation. #72
Copy link
Copy link
Closed
Description
The implementation borrowed from mitata is incorrect and off by at least one for all quantiles.
Correct implementation:
const quantileSorted = (arr, q) => {
const base = (arr.length - 1) * q;
const baseIndex = Math.floor(base);
if (arr[baseIndex + 1] != null) {
return (
arr[baseIndex] +
(base - baseIndex) * (arr[baseIndex + 1] - arr[baseIndex])
);
}
return arr[baseIndex];
};Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels