# percentile

> Calculate a percentile for given array of values

Latest version **1.6.0** (published 2021-11-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install percentile
pnpm add percentile
yarn add percentile
bun add percentile
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.6.0 |
| Published | 2021-11-18 |
| First published | 2015-11-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 30 |
| Author | Stanislav Sysoev |
| Maintainers | sysoev |
| Keywords | math, calculate, stats, percentile |

## Links

- npm: https://www.npmjs.com/package/percentile
- Repository: https://github.com/d4rkr00t/percentile
- Homepage: https://github.com/d4rkr00t/percentile#readme
- Issues: https://github.com/d4rkr00t/percentile/issues
- npm.io page: https://npm.io/package/percentile

## Alternatives

- [random-seedable](https://npm.io/package/random-seedable.md) — 27.9K weekly downloads
- [n2words](https://npm.io/package/n2words.md) — 22.2K weekly downloads
- [@stdlib/math-base-special-factorialln](https://npm.io/package/@stdlib/math-base-special-factorialln.md) — 5.7K weekly downloads
- [@stdlib/math-base-special-abs2](https://npm.io/package/@stdlib/math-base-special-abs2.md) — 1.7K weekly downloads
- [commons-math-interpolation](https://npm.io/package/commons-math-interpolation.md) — 1.4K weekly downloads

## Recent versions

- 1.6.0 (latest) — 2021-11-18
- 1.5.0 — 2021-07-21
- 1.4.0 — 2020-06-25
- 1.3.0 — 2020-04-24
- 1.2.3 — 2020-03-15
- 1.2.2 — 2019-06-24
- 1.2.1 — 2018-07-05
- 1.2.0 — 2016-12-27
- 1.1.0 — 2016-02-08
- 1.0.0 — 2015-11-30

## README

# percentile

[![npm](https://img.shields.io/npm/v/percentile.svg)](https://www.npmjs.com/package/percentile)
[![license](https://img.shields.io/npm/l/percentile.svg)](http://opensource.org/licenses/MIT)
[![github-issues](https://img.shields.io/github/issues/d4rkr00t/percentile.svg)](https://github.com/d4rkr00t/percentile/issues)
[![Build](https://github.com/d4rkr00t/percentile/actions/workflows/build.yml/badge.svg)](https://github.com/d4rkr00t/percentile/actions/workflows/build.yml)
[![coveralls](https://img.shields.io/coveralls/d4rkr00t/percentile.svg)](https://coveralls.io/github/d4rkr00t/percentile)
[![commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)

Calculate a percentile for given array of values.

## Install

```sh
npm install percentile
```

## Usage

```js
// 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

- **MIT** : http://opensource.org/licenses/MIT

## Contributing

Contributing are highly welcome! This repos is commitizen friendly — please read about it [here](http://commitizen.github.io/cz-cli/).

---
_Source: https://npm.io/package/percentile · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
