Math · Live
Median calculator,
with quartiles and IQR.
Paste any dataset and instantly see the median, full five-number summary, an interactive box-and-whisker plot, step-by-step computation, a sorted display with the median highlighted, and automatic outlier detection using the 1.5 × IQR rule.
Dataset
Enter your numbers
- Count (n)
- 13
- Range
- 40
- Mean
- 75.84615385
- Median
- 77
Median
n = 13 · odd
IQR = 17 · Q1 = 68 · Q3 = 85
Five-number summary
Min · Q1 · Median · Q3 · Max
Minimum
55
0th pct.
Q1
68
25th pct.
Median
77
50th pct.
Q3
85
75th pct.
Maximum
95
100th pct.
Box-and-whisker plot
Working
How the median is computed
- 1
Sort all 13 values in ascending order
55, 60, 63, 68, 71, 72, 77, 79, 82, 85, 88, 91, …
- 2
n = 13 (odd): take the single middle value
Median = value at position 7 = 77
Sorted dataset
Values in ascending order
Descriptive statistics
Complete summary
- Count (n)
- 13
- Sum
- 986
- Min
- 55
- Max
- 95
- Range
- 40
- Mean
- 75.84615385
- Median
- 77
- Mode
- No mode
- Q1 (25th pct.)
- 68
- Q3 (75th pct.)
- 85
- IQR
- 17
- Std dev (s)
- 12.34130027
Field guide
The median, quartiles, IQR, and what they tell you about your data.
The median is the middle value of a dataset when the values are arranged in order. It is one of the three main measures of central tendency (alongside the mean and the mode), and is frequently the most informative of the three, particularly when the dataset contains extreme values, skew, or outliers.
How to calculate the median
The procedure depends on whether you have an odd or even number of values:
- Sort the data in ascending (or descending) order.
- Count the values (n).
- If
nis odd: the median is the single middle value at position(n + 1) / 2. - If
nis even: the median is the average of the two middle values at positionsn / 2andn / 2 + 1.
Example (odd): data = [3, 7, 9, 2, 5]. Sorted: [2, 3, 5, 7, 9]. n = 5 (odd). Middle position = 3. Median = 5.
Example (even): data = [4, 8, 6, 2]. Sorted: [2, 4, 6, 8]. n = 4 (even). Middle positions = 2 and 3. Median = (4 + 6) / 2 = 5.
Median vs. mean: when to use each
The mean (arithmetic average) is sensitive to extreme values. A single very large or very small observation pulls the mean toward it, making it an unreliable representation of the "typical" value in skewed datasets. The median is resistant to outliers, adding one arbitrarily large value to a dataset of 99 values changes the mean substantially but moves the median by at most one position.
Common practical examples:
- Household income: a small number of very high earners pull the mean income far above what most people earn. Median household income is universally reported by statistics agencies because it better reflects the "typical" household.
- House prices: a few luxury properties inflate the mean. Real estate uses median sale price as the standard benchmark.
- Response times / latency: a handful of extreme slow responses inflate the mean. Median (or p50) latency is a more stable signal of typical user experience.
- Academic test scores: if the distribution is roughly symmetric and unimodal, mean and median are close. If a few students score very high or very low, the median is more representative of the typical student's performance.
Quartiles and the five-number summary
Quartiles divide a sorted dataset into four equal parts. The terminology is standard across statistics, data science, and finance:
- Q1 (first quartile / 25th percentile): 25% of values fall at or below this number. Also called the "lower quartile".
- Q2 (second quartile / 50th percentile): the median. Half the values fall below, half above.
- Q3 (third quartile / 75th percentile): 75% of values fall at or below this number. Also called the "upper quartile".
Together with the minimum and maximum, Q1, Q2, and Q3 form the five-number summary: the complete description of a dataset's spread and shape that does not depend on any distributional assumptions.
Quartile computation methods
There are several methods for computing quartiles; the most common in modern software is the linear interpolation method (Type 7), used by default in R, NumPy, Excel's QUARTILE.INC, and this calculator. It places Q1 at the (n−1)×0.25 position and Q3 at the (n−1)×0.75 position of the sorted array, interpolating linearly between adjacent values when the position is not an integer index.
For small datasets the method matters: a 4-value dataset [2, 4, 6, 8] gives Q1 = 3, Q3 = 7 (average of adjacent values) under this method, while some textbooks define Q1 = 4 by taking the median of the lower half. Differences vanish as n grows large. This calculator uses the Type-7 / linear interpolation convention consistently.
Interquartile Range (IQR)
The IQR measures the spread of the middle 50% of the data — the distance between the upper and lower quartiles. It is the most widely used robust measure of spread because, like the median, it is not distorted by extreme values.
The IQR directly determines the size of the box in a box plot and is the basis for Tukey's fence outlier rule. A large IQR relative to the median indicates high variability in the core of the distribution.
Box-and-whisker plot
The box plot (invented by John Tukey in 1970) is a standardised graphical representation of the five-number summary:
- The box spans Q1 to Q3 — the IQR.
- A vertical line inside the box marks the median.
- Whiskers extend from the box to the furthest non-outlier value (no further than 1.5 × IQR from the box edges).
- Individual points beyond the whiskers are plotted as dots and flagged as outliers.
Box plots are especially useful for comparing multiple distributions side by side and for quickly identifying skew (the median line inside the box will be closer to Q1 in right-skewed data and closer to Q3 in left-skewed data).
Outlier detection: the 1.5 × IQR (Tukey fence) rule
The most widely used heuristic for flagging outliers in exploratory data analysis:
Upper fence = Q3 + 1.5 × IQR
Values outside these fences are called mild outliers. Values beyond 3 × IQR from the quartiles are called extreme outliers. Under a normal distribution, roughly 0.7% of values fall outside the mild fences, so in a dataset of 100 normally distributed values, you'd expect fewer than one outlier by this rule.
Important: the Tukey fence rule flags potential outliers for further investigation, not automatic exclusion. An outlier may represent a data entry error (worth correcting), a genuine extreme event (worth keeping), or a sampling anomaly (worth investigating). Context always determines the appropriate response.
Percentiles and the median
The median is the 50th percentile: exactly half the dataset falls below it and half above. More generally, thepth percentile is the value below which p% of the data falls. Percentiles are widely used in growth charts, standardised tests, performance benchmarks, and financial risk measures (e.g., Value at Risk at the 5th percentile).
The quartiles correspond to specific percentiles: Q1 = 25th, Q2 = 50th (median), Q3 = 75th. The IQR therefore spans the 25th to 75th percentile range — the central half of the distribution.
When is the median more appropriate than the mean?
Use the median as your primary measure of centre when:
- The data is skewed (not symmetric).
- There are known or suspected outliers.
- The distribution is heavy-tailed (frequent extreme values).
- You are measuring ordinal data (rankings, Likert scale responses).
- You want a measure that minimises mean absolute deviation from the centre — the median does this optimally, while the mean minimises the mean squared deviation.
Use the mean when the data is approximately symmetric, normally distributed, or when downstream calculations require it (e.g., computing variance, t-tests, regression).