tinybench
tinybench copied to clipboard
Incorrect quantile computation.
The implementation borrowed from mitata is incorrect and off by at least one for all quantiles.
Correct implementation:
const quantile = (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];
};
Upvote & Fund
- We're using Polar.sh so you can upvote and help fund this issue.
- We receive the funding once the issue is completed & confirmed by you.
- Thank you in advance for helping prioritize & fund our backlog.
Interesting, could you send a PR with a test?