percentile
Calculate a percentile for given array of values
Last updated 7 days ago by sysoev .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install percentile 
SYNC missed versions from official npm registry.

percentile

npm license github-issues travis-status coveralls commitizen friendly

Calculate a percentile for given array of values.

Install

npm install percentile

Usage

// With simple values
const percentile = require("percentile");
console.log(percentile(80, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10])); // 8

// With complex values
const percentile = require("percentile");
const result = percentile(
  80,
  [
    { val: 1 }, { val: 2 }, { val: 3 }, { val: 4 }, { val: 5 },
    { val: 6 }, { val: 7 }, { val: 8 }, { val: 9 }, { val: 10 }
  ],
   // function to extract a value from an object
  item => item.val
);
console.log(result); // 8

// With array of percentiles
const percentile = require("percentile");
const result = percentile(
  [70, 80, 90], // calculates 70p, 80p and 90p in one pass
  [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
);
console.log(result); // [7, 8, 9]

Notes

Non-numeric (NaN) values are treated as the smallest values, Eg percentile(50, [ 5, 2, NaN]) === 2

Author

Stanislav Sysoev d4rkr00t@gmail.com https://github.com/d4rkr00t

License

Contributing

Contributing are highly welcome! This repos is commitizen friendly — please read about it here.

Current Tags

  • 1.4.0                                ...           latest (7 days ago)

8 Versions

  • 1.4.0                                ...           7 days ago
  • 1.3.0                                ...           2 months ago
  • 1.2.3                                ...           4 months ago
  • 1.2.2                                ...           a year ago
  • 1.2.1                                ...           2 years ago
  • 1.2.0                                ...           4 years ago
  • 1.1.0                                ...           4 years ago
  • 1.0.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 12
This Month 2
Last Day 2
Last Week 19
Last Month 41
Dependencies (0)
None
Dev Dependencies (10)

Copyright 2014 - 2017 © taobao.org |