# Percentile Calculator

> For a list of numbers, computes the value at a given percentile (linear interpolation, as in Excel PERCENTILE.INC) and/or the percentile rank of a given value (percentage of values below it, counting ties as half).

- Calculator id: `percentile` · Category: Statistics & Probability (`statistics`) · Tool name: `calculate_percentile`
- Canonical page: https://tttkmbb.com/statistics/percentile · This document: https://tttkmbb.com/statistics/percentile.md · JSON definition: https://tttkmbb.com/statistics/percentile.json

## Purpose

For a list of numbers, computes the value at a given percentile (linear interpolation, as in Excel PERCENTILE.INC) and/or the percentile rank of a given value (percentage of values below it, counting ties as half).

**Use when:** You need the k-th percentile of a data set (e.g. the 90th percentile response time) or want to know what percentile a particular value falls at within the data.

**Do not use when:** You want a percentile from a normal distribution rather than actual data (use z-score or normal-distribution), or you need quartiles together with other summary statistics (use descriptive-statistics).

## Input

| Parameter | Type | Unit | Required | Description |
| --- | --- | --- | --- | --- |
| `values` | number_list |  | required | The data set (order does not matter). |
| `percentile` | number | % | optional | Percentile between 0 and 100 whose value you want (e.g. 90 for the 90th percentile). Give this, value, or both. (min 0, max 100) |
| `value` | number |  | optional | A value whose percentile rank within the data you want. Give this, percentile, or both. |

## Output

| Field | Type | Unit | Description |
| --- | --- | --- | --- |
| `value_at_percentile` | number |  | Data value at the requested percentile by linear interpolation between sorted values (only when percentile is given). |
| `percentile_rank` | number | % | 100 × (count below + 0.5 × count equal) / n (only when value is given). |
| `count_below` | integer |  | Number of data values strictly less than value. |
| `count_equal` | integer |  | Number of data values equal to value. |
| `count` | integer |  | Size of the data set. |

## Formula

`value at percentile p: rank = p/100 · (n − 1) on the sorted data, value = x(⌊rank⌋) + (rank − ⌊rank⌋) · (x(⌊rank⌋+1) − x(⌊rank⌋)); percentile rank of v = 100 · (count(x < v) + 0.5 · count(x = v)) / n`

The value-at-percentile method is Hyndman & Fan type 7 (Excel PERCENTILE.INC, R and NumPy default); the 'exclusive' method and nearest-rank method give different results for small n. Percentile rank uses the definition with ties counted as half.

## Data Sources

- Wikipedia – Percentile — https://en.wikipedia.org/wiki/Percentile (reference, retrieved 2026-09-23)
- Wikipedia – Percentile rank — https://en.wikipedia.org/wiki/Percentile_rank (reference, retrieved 2026-09-23)
- Microsoft Support – PERCENTILE.INC function — https://support.microsoft.com/en-us/office/percentile-inc-function-680f9539-45eb-410b-9a5e-c1355e5fe2ed (reference, retrieved 2026-09-23)

Data freshness: `static`. Deterministic formula with fixed constants; results never go stale. Inputs supplied by the caller determine the output.

## API

- `GET https://tttkmbb.com/api/v1/calculate/percentile?values=…`
- `POST https://tttkmbb.com/api/v1/calculate/percentile` with JSON body `{"inputs": {…}}`
- Response: unified envelope (`success`, `request`, `result.values`, `result.units`, `sources`, `freshness`, `timestamp`, `next_actions`, `links`); see https://tttkmbb.com/docs/response-format.md
- Schema: https://tttkmbb.com/api/v1/calculators/percentile · OpenAPI operationId `calculate_percentile` in https://tttkmbb.com/openapi.json
- Authentication: none. Rate limit: fair use, see https://tttkmbb.com/docs/rate-limits.md.

## MCP

- Server: `https://tttkmbb.com/mcp` (Streamable HTTP, JSON-RPC 2.0, no auth)
- Tool:  `run_calculator` with `{"calculator_id": "percentile", "inputs": {…}}`

## Example

- 40th percentile of 15, 20, 35, 40, 50: inputs `{"values":[15,20,35,40,50],"percentile":40}` → `{"value_at_percentile":29,"count":5}`
- Rank of 5 and 90th percentile in 2, 4, 4, 4, 5, 5, 7, 9: inputs `{"values":[2,4,4,4,5,5,7,9],"value":5,"percentile":90}` → `{"percentile_rank":62.5,"count_below":4,"count_equal":2,"value_at_percentile":7.6,"count":8}`

```
GET https://tttkmbb.com/api/v1/calculate/percentile?values=15%2C20%2C35%2C40%2C50&percentile=40
```

## Limitations

You want a percentile from a normal distribution rather than actual data (use z-score or normal-distribution), or you need quartiles together with other summary statistics (use descriptive-statistics). The value-at-percentile method is Hyndman & Fan type 7 (Excel PERCENTILE.INC, R and NumPy default); the 'exclusive' method and nearest-rank method give different results for small n. Percentile rank uses the definition with ties counted as half. All values are computed from the formula above; no measurement or live data is involved.

## FAQ

**Why does Excel give a different number?**

PERCENTILE.INC matches this calculator; PERCENTILE.EXC uses rank = p·(n + 1) and is undefined near the ends. Some textbooks use the nearest-rank method, which always returns an actual data value.

**How are ties handled in the percentile rank?**

Values equal to the query count as half below and half above, so the rank of the median of a symmetric data set is 50 %. A value below the minimum has rank 0 and above the maximum rank 100.

## Related

- [Descriptive Statistics Calculator](https://tttkmbb.com/statistics/descriptive-statistics.md) — Quartiles, median and spread of the same data.
- [Z-Score Calculator](https://tttkmbb.com/statistics/z-score.md) — Percentile under a normal distribution from mean and SD.
