Median Calculator

Calculate the median (middle value) of a set of numbers

About Median

The median is the middle value in a sorted dataset. If there is an even number of values, the median is the average of the two middle values.

The median is less affected by outliers than the mean, making it a robust measure of central tendency.

What Is the Median?

The median is the middle value of a dataset when arranged in order. It divides data into two equal halves—50% of values fall below and 50% above. Unlike the mean, the median is resistant to outliers, making it ideal for skewed distributions like income, house prices, and home sizes.

The median is actually the 50th percentile and Q2 (second quartile). It represents a "typical" value better than the mean when data has extreme values or is asymmetric.

Dataset TypeExample ValuesMeanMedianBetter Measure
Symmetric (no outliers)10, 20, 30, 40, 503030Either
With outlier10, 20, 30, 40, 2006030Median
Income (right-skewed)30k, 40k, 50k, 80k, 500k140k50kMedian
Test scores (symmetric)65, 70, 75, 80, 857575Either

Median Formula

For sorted data with n values: Odd n: Median = value at position (n+1)/2 Even n: Median = average of values at positions n/2 and (n/2)+1

Where:

  • n= Number of values in dataset
  • (n+1)/2= Middle position for odd n

How to Find the Median

Finding the median requires sorting data first, then locating the middle value. The process differs slightly for odd and even numbers of values.

StepOdd n Example (n=5)Even n Example (n=6)
1. List data8, 3, 9, 1, 58, 3, 9, 1, 5, 7
2. Sort ascending1, 3, 5, 8, 91, 3, 5, 7, 8, 9
3. Find middle position(5+1)/2 = 3rd3rd and 4th positions
4. Get median valueValue at 3rd = 5(5 + 7)/2 = 6
ResultMedian = 5Median = 6

For even n: The median is the average of the two middle values, which may or may not be an actual data point.

Median vs Mean: When to Use Each

The choice between median and mean depends on your data's distribution and purpose. Both are valid measures of central tendency, but they answer different questions.

FactorUse MedianUse Mean
Data distributionSkewed, non-normalSymmetric, normal
Outliers presentYes—median ignores themNo—or outliers are meaningful
Statistical inferenceNon-parametric testsParametric tests (t-tests)
Common applicationsIncome, house prices, ageTest scores, heights, weights
Question answered"What's typical?""What's the total ÷ count?"

Real-world example: US median household income (~$75,000) vs mean (~$100,000). The difference exists because high earners pull the mean up, but the median better represents what a "typical" household earns.

Quartiles and the Five-Number Summary

The median is part of a broader framework of quantiles that divide data into equal parts. Quartiles split data into four quarters, and together with min/max, form the five-number summary.

QuantileSymbolDefinitionInterpretation
MinimumMinSmallest valueLower bound
First QuartileQ1 (25th %ile)25% below thisLower quarter boundary
MedianQ2 (50th %ile)50% below thisCenter of data
Third QuartileQ3 (75th %ile)75% below thisUpper quarter boundary
MaximumMaxLargest valueUpper bound

The Interquartile Range (IQR) = Q3 - Q1 measures spread resistant to outliers. Values beyond Q1 - 1.5×IQR or Q3 + 1.5×IQR are often flagged as potential outliers.

Box Plots: Visualizing the Median

A box plot (box-and-whisker plot) displays the five-number summary visually, making it easy to see distribution shape, center, spread, and outliers at a glance.

Box Plot ElementRepresentsWhat It Shows
Box left edgeQ1 (25th percentile)Start of middle 50%
Line inside boxMedian (Q2)Center of data
Box right edgeQ3 (75th percentile)End of middle 50%
Box widthIQR (Q3 - Q1)Spread of middle 50%
WhiskersRange (within 1.5×IQR)Non-outlier range
Individual pointsOutliersExtreme values

Box plots are excellent for comparing distributions across groups (e.g., salaries by department, scores by grade level).

Median for Grouped Data

When data is presented in frequency tables or histograms (grouped data), you estimate the median using interpolation within the median class—the class containing the middle value.

Class IntervalFrequencyCumulative Frequency
0-1055
10-201217
20-3018 (median class)35
30-401045
40-50550

Grouped Data Median

Median = L + [(n/2 - CF) / f] × h

Where:

  • L= Lower boundary of median class
  • n= Total frequency
  • CF= Cumulative frequency before median class
  • f= Frequency of median class
  • h= Class width

Real-World Applications of the Median

The median is the preferred measure of central tendency in many fields where data is typically skewed or outlier-prone. Understanding these applications helps in choosing the right statistic.

FieldApplicationWhy Median?
EconomicsMedian household incomeHigh earners skew mean upward
Real EstateMedian home priceLuxury homes distort mean
HealthcareMedian survival timeLong survivors skew mean
DemographicsMedian ageRobust to outliers
SportsMedian career lengthSuperstars skew mean
WagesMedian hourly wageBetter represents "typical"

Media reporting: When you see "average salary" in news, check whether it's mean or median—the difference can be substantial (often 20-30% for income data).

Worked Examples

Finding Median (Odd Number of Values)

Problem:

Find the median of: 7, 3, 9, 1, 5, 8, 2

Solution Steps:

  1. 1Count values: n = 7 (odd)
  2. 2Sort ascending: 1, 2, 3, 5, 7, 8, 9
  3. 3Find middle position: (7+1)/2 = 4th position
  4. 4Identify value: 4th value is 5

Result:

Median = 5. Three values (1, 2, 3) are below, three (7, 8, 9) are above.

Finding Median (Even Number of Values)

Problem:

Find the median of: 12, 8, 15, 3, 20, 6

Solution Steps:

  1. 1Count values: n = 6 (even)
  2. 2Sort ascending: 3, 6, 8, 12, 15, 20
  3. 3Find middle positions: 3rd and 4th values
  4. 4Average middle values: (8 + 12) / 2 = 10

Result:

Median = 10. Note: 10 is not in the original data, but it correctly splits the sorted data in half.

Median vs Mean with Outliers

Problem:

Five employees earn: $40k, $45k, $50k, $55k, $300k. Compare mean and median salaries.

Solution Steps:

  1. 1Calculate mean: (40 + 45 + 50 + 55 + 300) / 5 = 490/5 = $98k
  2. 2Sort data: 40, 45, 50, 55, 300
  3. 3Find median: Middle value (3rd) = $50k
  4. 4Compare: Mean ($98k) is nearly double the median ($50k)

Result:

Median ($50k) better represents typical salary. The mean ($98k) is inflated by the $300k outlier—more than any of 4 employees actually earn.

Tips & Best Practices

  • Always sort data before finding the median—the middle position only makes sense in ordered data.
  • For quick estimation in large datasets, the median is approximately at position (n+1)/2, whether n is odd or even.
  • When comparing groups, report both median and mean—a large gap indicates skewness.
  • The median is the 50th percentile, Q2, and the second quartile—these are all the same thing.
  • For grouped data, use the interpolation formula; for raw data, use the direct method.
  • In box plots, the line inside the box is the median—use this for quick visual comparison across groups.
  • Median is robust to outliers, so it won't change much if you add or remove extreme values.

Frequently Asked Questions

Income distributions are right-skewed—most people earn moderate amounts, but a small number earn very high incomes. These high earners pull the mean up significantly. For US household income, the mean (~$100k) is about 30% higher than the median (~$75k). The median better represents what a 'typical' household actually earns.
Yes, when the dataset has an even number of values. The median is then the average of the two middle values, which may not equal any actual data point. For example, the median of {1, 2, 3, 4} is 2.5, which isn't in the data.
Yes, the median is always between (or equal to) the minimum and maximum values. Since it's the middle value of sorted data, it can't be outside the data range. For {1, 3, 5}, the median is 3; for {1, 5}, the median is 3, which is still between 1 and 5.
Outliers barely affect the median because the median only depends on the middle value(s), not the extreme values. Changing 1, 3, 5, 7, 9 to 1, 3, 5, 7, 900 doesn't change the median (still 5), but dramatically changes the mean (from 5 to 183.2). This 'robustness' makes the median valuable for skewed data.
The median discards information about data extremes. Don't use it when: (1) data is symmetric with no outliers (mean uses all info); (2) you need mathematical properties like additivity; (3) you're doing parametric statistical tests; (4) outliers carry meaningful information you want to capture.
The median is exactly the 50th percentile (also called Q2 or the second quartile). It means 50% of values fall below and 50% above. Similarly, Q1 is the 25th percentile and Q3 is the 75th percentile. Percentiles generalize the concept of the median to any percentage threshold.

Sources & References

Last updated: 2026-01-22