Calculate Median
statistics.median
Overview
You send a numeric vector and we return the sample median. An odd-length series uses the middle order statistic; an even-length series uses the overflow-safe mean of the two central values. JSON nulls are refused by default or omitted when you set nullPolicy to OMIT. This is binary floating point, not the exact-decimal statistics.mean family. Do not use it for a weighted median, streaming quantiles, or grouped statistics.
Agents guess a middle value from unsorted series and disagree on even length. One overflow-safe definition removes that fork.
Reliability
The answer is invariant under permutation. Negative zero is published as 0.0. SERIES_INVALID — trigger: every observation was null under OMIT, or a null arrived under REJECT; retryable: no; next: send at least one finite number, or switch nullPolicy to OMIT only when dropping nulls is intended. ITEM_LIMIT_EXCEEDED — trigger: more than 100000 observations; retryable: no; next: split the series.
Context footprint
One bounded vector in, one median out. A successful call costs 1 execution credit.
When to use it
When you need the middle of a bounded numeric series and the mean would be pulled by tails.
When you need an exact-decimal mean, a probability other than one half, or a robust scale.
Scope
Non-goals
- Does not compute a weighted, grouped, or streaming median
- Does not use exact decimal arithmetic — that remains statistics.mean
Properties
Capabilities
Cost & billing
Flat rate per invocation
File handling
How we handle your data
What this means
This skill may receive sensitive content, but it does not target sensitive data and returns only a structured non-sensitive result.
Squillify guarantees
- Runs inside Squillify
- This skill runs inside Squillify.
- Payloads are not sent to an external service by this skill.
- Squillify does not permanently store submitted payloads.
- Telemetry records metadata only, not submitted content.
- Submitted payloads are not used for training.
- Submitted payloads are not reviewed by humans.
- This skill does not target sensitive data.
- The response does not contain submitted content.
Your responsibility
Squillify does not determine whether submitted content is sensitive. Your application is responsible for deciding what data it is allowed to submit. Your application is responsible for securing the response.
Input schema
| Field | Type | Required | Description |
|---|---|---|---|
| values | array | Yes | Required 1 to 100000 finite numbers. One extra slot exists in the schema so the typed ITEM_LIMIT_EXCEEDED failure is reachable at 100001. |
| nullPolicy | string | No | REJECT fails on any JSON null; OMIT drops nulls and reports omittedCount. Omit this field and we REJECT. |
Output schema
| Field | Type | Required | Description |
|---|---|---|---|
| median | number | Yes | Sample median after null policy and negative-zero canonicalization. |
| count | integer | Yes | Finite observations used. |
| omittedCount | integer | Yes | How many JSON null observations were dropped under OMIT; zero under REJECT. |
API contract
POST /v1/executecurl -sS -X POST "$BASE/v1/execute" -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' -d '{"skillKey":"statistics.median","input":{"values":[1,3,2]}}'import { Squillify } from "@squillify/sdk";
const sq = new Squillify({ apiKey: process.env.SQUILLIFY_API_KEY });
const { output } = await sq.execute("statistics.median", {"values":[1,3,2]});Errors
| Code | HTTP | Retryable | Description |
|---|---|---|---|
| VALIDATION_ERROR | 400 | No | The request payload failed schema validation. |
| UNAUTHORIZED | 401 | No | Missing or invalid API key. |
| SKILL_NOT_ACCESSIBLE | 403 | No | The API key is not granted access to this skill. |
| SKILL_NOT_AVAILABLE_FOR_PLAN | 403 | No | This skill is not included in your current plan. |
| PLAN_ELIGIBILITY_UNAVAILABLE | 503 | Yes | Plan eligibility could not be decided. Retry after backoff. |
| SKILL_NOT_FOUND | 404 | No | The requested skill or version does not exist. |
| TENANT_RATE_LIMITED | 429 | Yes | Request rate limit exceeded. Retry after backoff. |
| QUOTA_EXCEEDED | 429 | Yes | Plan quota exhausted. Retryable once the quota period resets. |
| EXECUTION_TIMEOUT | 504 | Yes | Execution exceeded the allowed time budget. |
| SERIES_INVALID | 400 | No | The request payload failed this skill's input validation. |
| ITEM_LIMIT_EXCEEDED | 429 | No | A size, quota, rate, or time limit was exceeded. |
Other limits
| Limit | Value |
|---|---|
| Recommended inline bytes | 32 KiB |
Limitations
- Does not compute a weighted, grouped, or streaming median
- Does not use exact decimal arithmetic — that remains statistics.mean
- Exact-decimal fund accounting (use statistics.mean)
- A requested probability other than the 50% mark (use statistics.quantile)
How to call
POST /v1/execute (requires authentication)
{
"skillKey": "statistics.median",
"input": {
"values": [
1,
3,
2
]
}
}Examples
Odd-length median is the middle order statistic
{
"values": [
1,
3,
2
]
}{
"omittedCount": 0,
"median": 2,
"count": 3
}Even-length median is the mean of the two central values
{
"values": [
1,
2,
3,
4
]
}{
"omittedCount": 0,
"median": 2.5,
"count": 4
}Recommended use cases
- Robust centre of a bounded numeric series
- A permutation-invariant location statistic before quantile or MAD work
Avoid for
- Exact-decimal fund accounting (use statistics.mean)
- A requested probability other than the 50% mark (use statistics.quantile)
Related skills
Composable with
Safety & privacy
- Runs without calling any external service.
- Your payloads are never stored permanently.
- Telemetry captures metadata only — never your payload contents.
- We never train models on your payloads.
- No human reviews your payloads.