percentile-js

1.1.1 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i percentile-js

Weekly Downloads

6

Version

1.1.1

License

ISC

Unpacked Size

2.78 kB

Total Files

8

Last publish

Collaborators

  • stephenjjbrown