Median absolute deviation calculator
The median absolute deviation calculator measures how far values typically sit from the center of a dataset without letting a few extreme observations dominate the result.
Run — free
Provide a non-empty array of numbers and receive the data median, the number of observations, and the median absolute deviation, commonly abbreviated as MAD. Because it relies on medians rather than squared distances, this statistic is especially useful when a distribution is skewed, contains outliers, or needs a robust summary of variability.
What median absolute deviation measures
Median absolute deviation describes the typical distance between observations and the median of the dataset. The calculation begins by sorting the supplied numbers and finding their median. Next, it takes the absolute difference between every number and that median. The median of those differences is the final MAD. Because distances are made absolute, observations below and above the center contribute in the same direction. Because the final summary is another median, a small number of unusually large distances cannot pull the result upward as easily as they can affect a standard deviation. A MAD of zero means that at least half of the observations are exactly at the data median; it does not necessarily mean every value is identical. The result uses the same units as the original values, so a MAD calculated from seconds is expressed in seconds, while one calculated from kilograms is expressed in kilograms. This direct interpretation makes the measure useful as a compact, robust description of spread.
How to enter data and interpret the result
Supply one or more finite numbers in the values array. Integers, decimals, negative numbers, and repeated values are accepted. The order of the input does not matter because the calculator sorts copies of the data when locating medians. For an odd number of observations, the median is the middle sorted value. For an even number, it is the arithmetic mean of the two central values. The same rule is applied to the array of absolute deviations. The response includes count so you can confirm how many observations were evaluated, median so you can inspect the center used by the calculation, and median_absolute_deviation for the robust spread. An empty array is rejected because no median exists, and non-numeric or non-finite entries are rejected rather than silently discarded. That strict behavior prevents a result from representing only an undocumented subset of the supplied data and makes automated validation easier to trust.
When MAD is a useful choice
MAD is a strong choice when data may contain exceptional values, measurement glitches, long tails, or a naturally skewed distribution. A monitoring system can compare a new reading with a historical median and express the gap relative to the usual absolute deviation. Analysts can summarize salaries, response times, delivery delays, or sensor readings without allowing a handful of extremes to define the reported variability. It is also useful during exploratory analysis: compare the median and MAD across groups to find segments whose typical levels or consistency differ. Remember that this calculator returns the raw, unscaled median absolute deviation. Some statistical workflows multiply MAD by a consistency factor when estimating a normal-distribution standard deviation; that scaling is intentionally not applied here. Keeping the raw definition avoids hidden assumptions about distribution shape. If your method requires a scaled estimate, apply the factor specified by that method after receiving this deterministic result.
What you can do with it
Monitor noisy measurements
Establish a robust baseline spread for sensor or service measurements that may occasionally contain extreme readings.
Compare group consistency
Compare the typical variability of delivery times, prices, or performance values across several groups.
Prepare robust outlier rules
Use the data median and raw MAD as inputs to an explicit, documented outlier-detection method.
FAQ
What does this calculator return?
It returns the observation count, the median of the supplied values, and the raw median absolute deviation.
What happens when the array is empty?
The request fails with an invalid-input error because neither the data median nor MAD is defined for an empty array.
Does input order affect MAD?
No. Values are sorted when each median is calculated, so permutations of the same numeric array produce the same result.
Is the MAD scaled for a normal distribution?
No. The result is the raw median of absolute deviations from the data median, with no consistency factor applied.
How much does an API request cost?
Each API request costs $0.002. The browser version can run the same deterministic calculation locally.
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/stat/median-absolute-deviation \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"values":[1,1,2,2,4,6,9]}'const res = await fetch("https://api.kit.forhosting.com/stat/median-absolute-deviation", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"values": [
1,
1,
2,
2,
4,
6,
9
]
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/stat/median-absolute-deviation",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"values": [
1,
1,
2,
2,
4,
6,
9
]
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/stat/median-absolute-deviation", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"values":[1,1,2,2,4,6,9]}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"values":[1,1,2,2,4,6,9]}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/stat/median-absolute-deviation", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"values": [
1,
1,
2,
2,
4,
6,
9
]
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "stat.median_absolute_deviation",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |