Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect quantile computation. #72

Open
jerome-benoit opened this issue Apr 10, 2024 · 1 comment
Open

Incorrect quantile computation. #72

jerome-benoit opened this issue Apr 10, 2024 · 1 comment
Labels

Comments

@jerome-benoit
Copy link

jerome-benoit commented Apr 10, 2024

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
@Aslemammad
Copy link
Member

Interesting, could you send a PR with a test?

@polar-sh polar-sh bot added the fund label Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants