percentile-js
v1.1.1
Published
A basic percentile function with linear interpolation
Downloads
5
Readme
Percentile
A simple percentile function for JavaScript (or TypeScript) with linear interpolation, taking O(1) time. This is basically an implementation of the C = 1 algorithm here—the same one used by Excel via the PERCENTILE or PERCENTILE.INC formula functions.
Example
import { percentile } from "percentile-js";
percentile(0.5, [0, 300, 600]);
// 300
percentile(0.75, [0, 300, 600]);
// 450 -- interpolated
percentile(1, [0, 300, 600]);
// 600