Median Calculator

Find the median (middle value) of any list of numbers. Enter your values below, and see the formula, a worked example, and ready-to-use Python code underneath.

Enter your data

Separate values with commas, spaces, or new lines — e.g. 12, 15, 9, 21, 14

Please enter at least one valid number.

Median
Count (n)
Sorted data

What the median tells you

The median is the value that sits exactly in the middle of a data set once it's sorted from smallest to largest: half the values fall below it, and half fall above it. Unlike the mean, the median doesn't add up every value — it only looks at their order — which makes it far less sensitive to a handful of extreme values.

That property makes the median a common choice for skewed data. Household income and home prices, for example, are usually summarized with a median rather than a mean, because a small number of very high values would otherwise drag the mean well above what a "typical" observation looks like.

Median formula

Odd n:  median = x₍₍ₙ₊₁₎/₂₎
Even n:  median = ( x₍ₙ/₂₎ + x₍ₙ/₂ ₊ ₁₎ ) / 2
Sort the data first. With an odd number of values (n), the median is the single middle value. With an even number of values, it's the average of the two middle values.

Python code

You can compute the median by sorting the data by hand, or with Python's built-in statistics module:

# Method 1 — manual calculation
data = [12, 15, 9, 21, 14]
sorted_data = sorted(data)
n = len(sorted_data)
mid = n // 2
if n % 2 == 1:
    median_value = sorted_data[mid]
else:
    median_value = (sorted_data[mid - 1] + sorted_data[mid]) / 2
print(median_value)  # 14

# Method 2 — statistics module
import statistics
median_value = statistics.median(data)

# Method 3 — NumPy
import numpy as np
median_value = np.median(data)

Worked example

Using the same five quiz scores as the mean calculator example: 12, 15, 9, 21, and 14.

  1. 1
    Sort the values from smallest to largest.
    9, 12, 14, 15, 21
  2. 2
    Count the values.
    n = 5, which is odd, so there's a single middle position.
  3. 3
    Find the middle value.
    The middle position is (5 + 1) / 2 = 3rd value, which is 14.

The median quiz score is 14 — close to, but not identical to, the mean of 14.2 for this data set.

If there were six scores instead — say 9, 12, 14, 15, 21, 22 — n would be even, so the median would be the average of the 3rd and 4th values: (14 + 15) / 2 = 14.5.

Frequently asked questions

What is the difference between mean and median?

The mean adds up every value and divides by the count, so every value pulls on the result. The median sorts the values and picks the middle one, so it depends only on the data's order, not the exact size of each value. This makes the median more resistant to outliers and skewed data.

How is the median calculated when there's an even number of values?

Sort the values, then average the two values in the middle. For example, in the sorted list 2, 4, 6, 8, the two middle values are 4 and 6, so the median is (4 + 6) / 2 = 5.

Is the median resistant to outliers?

Yes. Because the median only depends on the position of values once sorted, not their magnitude, a single extremely large or small value has little or no effect on it. This is why the median is often preferred over the mean for skewed data, such as income or house prices.

Can the median be a value that isn't in the data set?

Yes, when there's an even number of values. The median is then the average of the two middle values, and that average won't always match one of the original numbers. With an odd number of values, the median is always one of the actual data points.

Do I need to sort my data before using this calculator?

No. You can enter your numbers in any order — the calculator sorts them automatically before finding the median.

Advertisement