Skip to main content

Squillify development is paused indefinitely. Read why, and discover what this experiment achieved. Read the story

MicroSkills Reference

Calculate Median

statistics.median

ProductionBounded custom (Class B)Deterministicstrictinstantv1.0.0
No network

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

Note
Returns the sample median of one bounded finite numeric vector.

Non-goals

  • Does not compute a weighted, grouped, or streaming median
  • Does not use exact decimal arithmetic — that remains statistics.mean

Properties

IdempotentRetry safeStreaming supportedFile input supportedRequires external service

Capabilities

analysismath

Cost & billing

Flat rate per invocation

MetercallsBillable onsuccessCost per call1 credit

File handling

Accepts file_refProduces file_refMax input2 MB

How we handle your data

Sensitive input, safe output
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.

Read the Microskill Data Handling Policy

Input schema

FieldTypeRequiredDescription
valuesarrayYesRequired 1 to 100000 finite numbers. One extra slot exists in the schema so the typed ITEM_LIMIT_EXCEEDED failure is reachable at 100001.
nullPolicystringNoREJECT fails on any JSON null; OMIT drops nulls and reports omittedCount. Omit this field and we REJECT.

Output schema

FieldTypeRequiredDescription
mediannumberYesSample median after null policy and negative-zero canonicalization.
countintegerYesFinite observations used.
omittedCountintegerYesHow many JSON null observations were dropped under OMIT; zero under REJECT.

API contract

POST /v1/execute
curl
curl -sS -X POST "$BASE/v1/execute" -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' -d '{"skillKey":"statistics.median","input":{"values":[1,3,2]}}'
Integrations
TypeScript SDK
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

CodeHTTPRetryableDescription
VALIDATION_ERROR400NoThe request payload failed schema validation.
UNAUTHORIZED401NoMissing or invalid API key.
SKILL_NOT_ACCESSIBLE403NoThe API key is not granted access to this skill.
SKILL_NOT_AVAILABLE_FOR_PLAN403NoThis skill is not included in your current plan.
PLAN_ELIGIBILITY_UNAVAILABLE503YesPlan eligibility could not be decided. Retry after backoff.
SKILL_NOT_FOUND404NoThe requested skill or version does not exist.
TENANT_RATE_LIMITED429YesRequest rate limit exceeded. Retry after backoff.
QUOTA_EXCEEDED429YesPlan quota exhausted. Retryable once the quota period resets.
EXECUTION_TIMEOUT504YesExecution exceeded the allowed time budget.
SERIES_INVALID400NoThe request payload failed this skill's input validation.
ITEM_LIMIT_EXCEEDED429NoA size, quota, rate, or time limit was exceeded.

Other limits

LimitValue
Recommended inline bytes32 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)

Request bodyjson
{
  "skillKey": "statistics.median",
  "input": {
    "values": [
      1,
      3,
      2
    ]
  }
}

Examples

Odd-length median is the middle order statistic

Inputjson
{
  "values": [
    1,
    3,
    2
  ]
}
Expected outputjson
{
  "omittedCount": 0,
  "median": 2,
  "count": 3
}
Tip
Sorted order is 1, 2, 3 so the middle value is 2

Even-length median is the mean of the two central values

Inputjson
{
  "values": [
    1,
    2,
    3,
    4
  ]
}
Expected outputjson
{
  "omittedCount": 0,
  "median": 2.5,
  "count": 4
}
Tip
The two central order statistics are 2 and 3
  • 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)

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.

Tags

analysismathstatistics