Median Calculator

Median Calculator

Growing AI Skill PRO

Enter Calculation

Formula

Median={xn+12n oddxn2+xn2+12n even\text{Median} = \begin{cases} x_{\frac{n+1}{2}} & n \text{ odd} \\[0.6em] \dfrac{x_{\frac{n}{2}} + x_{\frac{n}{2}+1}}{2} & n \text{ even} \end{cases}
Usage stats

Advertisement

Results

Median
40
middle value of the data set
Count of values 5
Sum 550
Mean (average) 110

Report an error on this page

What Is the Median?

The median is the middle value of a data set when the numbers are arranged in order from smallest to largest. Unlike the mean (average), the median is not skewed by extreme outliers, which makes it a robust measure of central tendency — especially useful for income, house prices, and other skewed data.

A row of sorted number tiles with the center tile highlighted as the median
The median is the middle value of a data set sorted in order.

How to Use This Calculator

Type your numbers into the box separated by commas or spaces (for example 4, 8, 15, 16, 23, 42) and the calculator sorts them, finds the median, and also reports the count, sum, and mean. There is no limit on how many values you can enter.

The Formula Explained

First sort the values. If the count n is odd, the median is the value in position \((n+1)/2\). If \(n\) is even, there is no single middle value, so the median is the average of the two central values — positions \(n/2\) and \(n/2+1\).

$$\text{Median} = \begin{cases} x_{\frac{n+1}{2}} & n \text{ odd} \\[0.6em] \dfrac{x_{\frac{n}{2}} + x_{\frac{n}{2}+1}}{2} & n \text{ even} \end{cases}$$

$$x = \operatorname{sort}\left(\text{Numbers}\right)$$

Advertisement
Comparison of finding the median for an odd count versus an even count of values
Odd counts have one middle value; even counts average the two central values.

Worked Example

Take the set 4, 8, 15, 16, 23, 42. It is already sorted and has 6 values (even). The two middle values are 15 and 16. The median is $$\frac{15 + 16}{2} = \textbf{15.5}$$ Now take 3, 7, 9 — an odd set of 3 — the middle value is simply 7.

Median vs. Mean: How Outliers Change the Result

The mean uses every value in its calculation, so one extreme value can pull it far from the typical value. The median depends only on the middle position, so it barely reacts to outliers. The table compares four small data sets. The gap is the mean minus the median.

Data set Count (n) Sum Mean Median Gap (mean − median)
Symmetric: 10, 20, 30, 40, 50 5 150 30 30 0
High outlier: 30, 35, 40, 45, 400 5 550 110 40 70
Duplicates: 3, 3, 3, 8, 13 5 30 6 3 3
Even-sized: 12, 15, 18, 20, 25, 30 6 120 20 19 1

In the outlier set, the mean of 110 is larger than four of the five values, while the median of 40 still describes the typical value well. In the symmetric set the two measures agree. When the mean is well above the median, the data is usually skewed toward high values. This is why the median is often preferred for skewed data such as incomes or property prices.

For the even-sized set, the median is \(\frac{18 + 20}{2} = 19\). It is not one of the data values, which is normal for an even count.

Advertisement

How to Find the Median by Hand

  1. List the values. Write down every number in the data set, including repeats.
  2. Sort ascending. Order the values from smallest to largest. Negative numbers come first, with the most negative at the start.
  3. Count n. Count all the values, counting duplicates each time they appear.
  4. Decide odd or even. Check whether n is odd or even.
  5. Pick the middle. If n is odd, the median is the value at position \(\frac{n+1}{2}\). If n is even, average the values at positions \(\frac{n}{2}\) and \(\frac{n}{2}+1\).

Odd example: 9, 3, 7, 1, 5 sorts to 1, 3, 5, 7, 9. Here n = 5, so the position is \(\frac{5+1}{2} = 3\), and the third value is 5.

Even example with a negative, a decimal and a duplicate: 7, −2, 3.5, 3.5, 10, 1 sorts to −2, 1, 3.5, 3.5, 7, 10. Here n = 6, so the middle positions are 3 and 4. Both hold 3.5, so the median is \(\frac{3.5 + 3.5}{2} = 3.5\).

Special cases

  • Duplicates: Keep every copy. Each one occupies a position when you count and sort.
  • Negative numbers: Sort them by true value, so −5 is less than −2. The usual rules then apply.
  • Decimals: Treat them like any other number. Compare their actual values when sorting, for example 3.05 is less than 3.5.
  • A single value: With n = 1 the position is \(\frac{1+1}{2} = 1\), so the value is its own median.
  • Two values: The median is their average.

Conventions and edge cases

Each case below was run through this calculator; the result column is what it actually returns.

CaseInputResult
Decimals 0.1, 0.2, 0.30.1, 0.2, 0.30.2
Even number of values (1, 2, 3, 4)1, 2, 3, 42.5
Negative values (−3, −1, 4)-3, -1, 4-1
A zero in the list (0, 4, 9)0, 4, 94
Sample or population (2, 4, 4, 4, 5, 5, 7, 9)2, 4, 4, 4, 5, 5, 7, 94.5
A single value77

Checked on 2026-11-08

FAQ

Is the median the same as the average? No. The average (mean) sums all values and divides by the count, while the median is the positional middle. They can differ greatly for skewed data.

Why use the median instead of the mean? The median resists outliers. One very large or very small value can drag the mean far from the typical value, but barely moves the median.

Do the numbers need to be sorted first? No — the calculator sorts them for you automatically.

Last updated:

Most popular in Math and Statistics

View all Math and Statistics calculators