Calculate Median Absolute Deviation
statistics.median_absolute_deviation
Overview
You send a numeric vector and we return the sample median, the raw MAD (median of absolute deviations from that median), and the same figure after an optional normal-consistent scale of 1.482602218505602. RAW, the default, leaves the multiplier at one. This is not the mean absolute deviation, a custom centre, or a multivariate robust distance.
Mean absolute deviation around the mean is a different number. Pinning the centre to the sample median, and the normal factor to one published constant, stops two robust-scale recipes from drifting.
Reliability
The centre equals statistics.median on the same vector. Translation leaves MAD unchanged; a positive scale factor scales it. SERIES_INVALID — trigger: every observation was null under OMIT, or a null arrived under REJECT; retryable: no; next: send at least one finite number. ITEM_LIMIT_EXCEEDED — trigger: more than 100000 observations; retryable: no; next: split the series.
Context footprint
One vector in, median plus MAD out. A successful call costs 1 execution credit.
When to use it
When you need a robust scale around the sample median, raw or normal-consistent.
When you need quartile spread, a mean-centred deviation, or an exact-decimal series.
Scope
Non-goals
- Does not compute mean absolute deviation or a caller-chosen centre
- Does not compute a multivariate robust distance
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. |
| scale | string | No | RAW leaves mad equal to rawMad; NORMAL_CONSISTENT applies 1.482602218505602. Omit this field and we use RAW. |
| 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 used as centre. |
| rawMad | number | Yes | Median of absolute deviations from the sample median, before any scale factor. |
| mad | number | Yes | rawMad, or rawMad times 1.482602218505602 when scale is NORMAL_CONSISTENT. |
| scale | string | Yes | RAW or NORMAL_CONSISTENT: the scale actually applied to produce mad. |
| 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_absolute_deviation","input":{"values":[1,2,3,4,5]}}'import { Squillify } from "@squillify/sdk";
const sq = new Squillify({ apiKey: process.env.SQUILLIFY_API_KEY });
const { output } = await sq.execute("statistics.median_absolute_deviation", {"values":[1,2,3,4,5]});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 mean absolute deviation or a caller-chosen centre
- Does not compute a multivariate robust distance
- Interquartile range as the spread (use statistics.interquartile_range)
- The arithmetic mean as the centre (use statistics.mean)
How to call
POST /v1/execute (requires authentication)
{
"skillKey": "statistics.median_absolute_deviation",
"input": {
"values": [
1,
2,
3,
4,
5
]
}
}Examples
Raw MAD of the integers one through five
{
"values": [
1,
2,
3,
4,
5
]
}{
"median": 3,
"count": 5,
"omittedCount": 0,
"scale": "RAW",
"rawMad": 1,
"mad": 1
}Normal-consistent scale on a constant series
{
"values": [
4,
4,
4
],
"scale": "NORMAL_CONSISTENT"
}{
"median": 4,
"count": 3,
"omittedCount": 0,
"scale": "NORMAL_CONSISTENT",
"rawMad": 0,
"mad": 0
}Recommended use cases
- A robust scale that matches the statistics.median centre
- Normal-consistent MAD when you need a sigma-like figure for Gaussian data
Avoid for
- Interquartile range as the spread (use statistics.interquartile_range)
- The arithmetic mean as the centre (use statistics.mean)
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.