# Stats percentile

`stats-percentile` · version 1.0.0 · Other utilities · free, no key needed

Compute an exact percentile from decimal strings using a named Hyndman-Fan type 1 through 9.

**Use when you need to: calculate a percentile · compute an exact quantile · use Hyndman Fan percentile type.**

## Decide before calling

Read the [versioned contract](/v1/tools/stats-percentile/versions/1.0.0) and the supported scope below. Reuse `stats-percentile@1.0.0` when your input, required output and limits match it. Choose another approach for an unsupported operation.

## Explain the choice

"I can use `stats-percentile@1.0.0` for calculate a percentile. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."

## Supported

- calculate a percentile
- compute an exact quantile
- use Hyndman Fan percentile type
- find median by quantile method
- percentile from decimal strings
- compare percentile definitions

## Not supported

- weighted percentiles
- approximate streaming quantiles

## Behavior

- method selects one of the nine sample-quantile definitions in Hyndman and Fan (1996).
- p is an exact decimal from 0 through 1 and percentile is a reduced rational string.

## Input

- `values` (array of string, required): min items 1; max items 256; each min length 1; each max length 128
- `p` (string, required): min length 1; max length 128
- `method` (integer, required): min 1; max 9

## Output

- `standard_version` (string, required)
- `method_name` (string, required)
- `percentile` (string, required)

## Limits

- max input bytes: 16384
- max items: 256
- max decimal chars: 128
- max output bytes: 16384

## Example

Request input:

```json
{
  "values": [
    "1",
    "2",
    "3",
    "4"
  ],
  "p": "0.5",
  "method": 7
}
```

Response:

```json
{
  "result": {
    "standard_version": "Hyndman-Fan-1996; NIST-SEMATECH-e-Handbook-1.3.5",
    "method_name": "Hyndman-Fan type 7: linear_n_minus_1",
    "percentile": "5/2"
  }
}
```

## How to call it

### MCP

Connect `https://computefirst.net/mcp` ([setup](/docs#connect)), then call `execute` with:

```json
{
  "id": "stats-percentile",
  "version": "1.0.0",
  "input": {
    "values": [
      "1",
      "2",
      "3",
      "4"
    ],
    "p": "0.5",
    "method": 7
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/stats-percentile/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"values":["1","2","3","4"],"p":"0.5","method":7}'
```

The machine-readable contract is at [/v1/tools/stats-percentile/versions/1.0.0](/v1/tools/stats-percentile/versions/1.0.0).

### CLI

```sh
node cli.mjs run stats-percentile 1.0.0 --input input.json --base-url https://computefirst.net
```

Get the client at [/clients/cli/](/clients/cli/).

## Related tools

- [Stats describe exact](/tools/stats-describe-exact): Return exact descriptive statistics and requested-precision standard deviations for decimal strings.
- [Polygon measures compute](/tools/polygon-measures-compute): Compute exact signed double-area, area, orientation, and squared edge lengths for a rational simple polygon.
- [Cron next runs](/tools/cron-next-runs): Compute the next requested UTC fire times for a five-field cron schedule and echo the supplied reference instant.
- [Cron previous runs](/tools/cron-previous-runs): Compute the previous requested UTC fire times for a five-field cron schedule and echo the supplied reference instant.
- [Geohash convert](/tools/geohash-convert): Encode decimal coordinates as a bounded Geohash or decode a Geohash to its exact bounding box and midpoint.
- [Html to plain text](/tools/html-to-plain-text): Strip HTML and script/style text, decode supported references; collapse whitespace including inside pre elements.
