Skip to main content

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

MicroSkills Reference

Calculate Median Absolute Deviation

statistics.median_absolute_deviation

ProductionBounded custom (Class B)Deterministicstrictfastv1.0.0
No network

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

Note
Returns the median absolute deviation around the sample median of one vector.

Non-goals

  • Does not compute mean absolute deviation or a caller-chosen centre
  • Does not compute a multivariate robust distance

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.
scalestringNoRAW leaves mad equal to rawMad; NORMAL_CONSISTENT applies 1.482602218505602. Omit this field and we use RAW.
nullPolicystringNoREJECT fails on any JSON null; OMIT drops nulls and reports omittedCount. Omit this field and we REJECT.

Output schema

FieldTypeRequiredDescription
mediannumberYesSample median used as centre.
rawMadnumberYesMedian of absolute deviations from the sample median, before any scale factor.
madnumberYesrawMad, or rawMad times 1.482602218505602 when scale is NORMAL_CONSISTENT.
scalestringYesRAW or NORMAL_CONSISTENT: the scale actually applied to produce mad.
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_absolute_deviation","input":{"values":[1,2,3,4,5]}}'
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_absolute_deviation", {"values":[1,2,3,4,5]});

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 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)

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

Examples

Raw MAD of the integers one through five

Inputjson
{
  "values": [
    1,
    2,
    3,
    4,
    5
  ]
}
Expected outputjson
{
  "median": 3,
  "count": 5,
  "omittedCount": 0,
  "scale": "RAW",
  "rawMad": 1,
  "mad": 1
}
Tip
Median 3, absolute deviations 2,1,0,1,2, whose median is 1

Normal-consistent scale on a constant series

Inputjson
{
  "values": [
    4,
    4,
    4
  ],
  "scale": "NORMAL_CONSISTENT"
}
Expected outputjson
{
  "median": 4,
  "count": 3,
  "omittedCount": 0,
  "scale": "NORMAL_CONSISTENT",
  "rawMad": 0,
  "mad": 0
}
Tip
Zero raw MAD stays zero after any positive scale factor
  • 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)

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