The median ( or ) is the positional center of a dataset—the exact value that divides a sorted sequence of numbers into a lower and an upper . Unlike the arithmetic mean, which weights every observation by its numerical magnitude, the median depends exclusively on the rank order of the data. This positional property makes it the premier robust measure of central tendency across descriptive statistics, economics, real estate valuation, and latency telemetry.
Whenever a dataset exhibits strong skewness or contains extreme outliers, the arithmetic average drifts toward the long tail of the distribution, misrepresenting what a typical observation looks like. By anchoring the 50th percentile alongside the first and third quartiles ( and ), the median provides a distortion-free summary of central location and non-parametric spread.
Mathematical Formulas for Ungrouped and Grouped Data
Before applying any median formula, the raw dataset must be sorted into non-decreasing order statistics:
where is the sample minimum and is the sample maximum.
1. Odd Number of Observations ( is odd)
When the total count is odd, a single unique value occupies the exact middle rank at index :
2. Even Number of Observations ( is even)
When is even, the midpoint falls between two central observations at positions and . The median is defined as the arithmetic average of these two middle order statistics:
3. Grouped Frequency Distribution Formula
When raw observations are aggregated into continuous class intervals (such as age brackets or income tiers), the exact median is interpolated linearly across the median class—the first interval whose cumulative frequency reaches or exceeds :
Variable Definitions
- : The -th order statistic (the value at position after sorting in ascending order).
- or : Total number of observations in the dataset.
- : Exact lower class boundary of the median class interval.
- : Cumulative frequency of all classes strictly preceding the median class.
- : Frequency (count of observations) inside the median class itself.
- : Class width of the median interval (upper boundary minus lower boundary).
Quartiles, Interquartile Range (IQR), and Outlier Fences
In exploratory data analysis, John Tukey introduced the Five-Number Summary—Minimum (), First Quartile (), Median (), Third Quartile (), and Maximum ()—which forms the structural basis of a box-and-whisker plot.
- First Quartile (, 25th Percentile): The median of the lower half of the sorted data.
- Second Quartile (, 50th Percentile): The overall dataset median .
- Third Quartile (, 75th Percentile): The median of the upper half of the sorted data.
- Interquartile Range (): The spread of the middle of observations, .
Using the , statisticians establish objective non-parametric boundaries (Tukey Fences) to flag outliers without assuming a normal distribution:
Additionally, the Median Absolute Deviation () quantifies typical distance from the median as an outlier-proof alternative to standard deviation.
Step-by-Step Worked Calculation Examples
Example 1: Odd and Even Samples with Outlier Resistance
Suppose a real estate analyst records recent residential sales (in thousands of dollars) on a residential street:
- Sort in Ascending Order: .
- Locate the Median Position (, Odd): At rank index , the 5th sorted value is . Compare this with the arithmetic mean (), where the single mansion pulls the average above eight of the nine homes.
- Compute Quartiles (), , and Outlier Fences:
- Lower Half : .
- Upper Half : .
- Interquartile Range: .
- Upper Outlier Fence: , confirming is a mathematical outlier.
- Even Sample (): Evaluating only the eight standard homes averages positions $4$ and $5$: .
Example 2: Grouped Frequency Table Median
Suppose server response times (in ms) are grouped into class intervals, where $18$ requests fall below () and $14$ requests fall within the bracket (). Since lands inside :
Reference Comparison: Distribution Shape & Central Tendency
| Distribution Shape | Mathematical Relationship | Optimal Center | Optimal Spread | Typical Domain Examples |
|---|---|---|---|---|
| Symmetric (Normal) | Arithmetic Mean () | Standard Deviation () | Human stature, manufacturing tolerances | |
| Right-Skewed (Positive) | Median () | Interquartile Range () | Household income, home prices, API latency | |
| Left-Skewed (Negative) | Median () | Interquartile Range () | Age at retirement, easy exam scores | |
| Ordinal / Ranked Scales | Non-metric rank order | Median () | or Percentile Range | Likert survey ratings, clinical pain scales |
| Heavy-Tailed / Cauchy | Population mean undefined | Median () | Median Absolute Deviation | High-frequency financial tick returns |