tinybench icon indicating copy to clipboard operation
tinybench copied to clipboard

Incorrect quantile computation.

Open jerome-benoit opened this issue 1 year ago • 1 comments

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.
Fund with Polar

jerome-benoit avatar Apr 10 '24 13:04 jerome-benoit

Interesting, could you send a PR with a test?

Aslemammad avatar Apr 10 '24 14:04 Aslemammad