just-percentile
TypeScript icon, indicating that this package has built-in type declarations

4.2.0 • Public • Published

just-percentile

Part of a library of zero-dependency npm modules that do just do one thing. Guilt-free utilities for every occasion.

🍦 Try it

npm install just-percentile
yarn add just-percentile

Return the value at the given percentile (using linear interpolation)

import percentile from 'just-percentile';

percentile([1, 2, 3], 0); // 1
percentile([1, 2, 3], 0.5); // 2
percentile([1, 2, 3], 1); // 3

// See https://en.wikipedia.org/wiki/Percentile (linear interpolation method)
percentile([15, 20, 35, 40, 50], 0.05); // 15
percentile([15, 20, 35, 40, 50], 0.3); // 20
percentile([15, 20, 35, 40, 50], 0.4); // 27.5
percentile([15, 20, 35, 40, 50], 0.95); // 50

percentile(1, 2, 3, 50); // throws
percentile(['1', 2, 3], 50); // throws
percentile([], 50); // throws

/just-percentile/

    Package Sidebar

    Install

    npm i just-percentile

    Weekly Downloads

    893

    Version

    4.2.0

    License

    MIT

    Unpacked Size

    6.98 kB

    Total Files

    9

    Last publish

    Collaborators

    • angus-c