Median Formula: Detailed Explanation with Examples

The Median Formula – Odd and Even Cases

The median is the middle value of a sorted dataset. To find it, you must first arrange all numbers in ascending order. The formula then depends on whether the number of data points, n, is odd or even.

When n is odd

Median = x_{(n+1)/2}

Here, x represents the sorted list, and the subscript (n+1)/2 gives the position of the middle value. For example, in the dataset {1, 3, 5, 7, 9} (n = 5), the median is the 3rd value: x_3 = 5.

When n is even

Median = (x_{n/2} + x_{(n/2)+1}) / 2

For an even number of values, there is no single middle value. Instead, take the average of the two middle numbers. For the dataset {1, 3, 5, 7} (n = 4), n/2 = 2 and (n/2)+1 = 3, so the median is (x_2 + x_3) / 2 = (3 + 5) / 2 = 4.

These formulas work for any set of numbers, whether whole numbers, decimals, or even negative values. For a step-by-step guide on applying them, see our How to Calculate Median: Step-by-Step Guide (2026).

Why the Median Works: Intuition and Historical Roots

The median is a measure of central tendency – it tells you where the center of your data lies. Unlike the mean, the median is not affected by extreme values (outliers). This makes it especially useful for skewed distributions or data with outliers, like income or housing prices.

Think of the median as the point that splits your sorted data into two equal halves. Half the values are below the median, half are above. This property holds true regardless of how far the extremes go. The formula simply finds that midpoint.

The concept of the median dates back to the 19th century. Sir Francis Galton, a pioneer in statistics, popularized the median as a robust alternative to the mean. He used it in his studies of heredity and variation. Today, the median is a standard tool in fields from economics to healthcare. If you want a broader definition, check out What Is the Median in Statistics? Definition & Examples (2026).

Practical Implications and Edge Cases

When to use the median

The median is ideal when your data has outliers or is skewed. For example, home prices in a city: a few mansions can pull the mean upward, but the median gives a better sense of the typical home. Similarly, in healthcare, median survival time is often reported because it isn't swayed by a few very long or very short survival times.

Large datasets

For large datasets, the median formula still applies, but you need to sort all values first. Sorting can be time-consuming for millions of points, but modern computers handle it efficiently. Our Median Calculator does the sorting and calculation instantly.

Duplicate values

The median formula works fine with duplicates. For an odd count with repeated values, the middle value is simply that number. For an even count, the two middle values might be the same, so the median equals that value. For instance, {2, 2, 2, 2} has median (2+2)/2 = 2.

Empty or single-value datasets

If the dataset is empty, the median is undefined. With one value, that value is the median (since it's the only middle). Our calculator handles these edge cases by returning a clear message.

Ordinal and categorical data

The median can also be used for ordinal data (e.g., rankings like 1st, 2nd, 3rd) because ordering is meaningful. The mean, however, is not appropriate for ordinal data. For interpreting what the median tells you in different contexts, visit Interpreting Median Values: What They Tell You (2026).

Common Mistakes and Misunderstandings

  • Forgetting to sort: The formula only works on sorted data. Always arrange values in ascending order first.
  • Using the wrong formula: Many people apply the formula for odd n to an even n and vice versa. Check your count carefully.
  • Confusing median with mean: They are different. The median is the middle; the mean is the average. The median is more robust to outliers.
  • Not handling duplicates properly: The formula automatically accounts for duplicates because you just take the value at that position.

The median formula is simple but powerful. By understanding its components and the logic behind them, you can correctly interpret data and choose the right measure of central tendency for your analysis. For more frequently asked questions, see our Frequently Asked Questions About the Median (2026).

Try the free Median Calculator ⬆

Get your The median is the middle value of a sorted dataset, a measure of central tendency robust to outliers. result instantly — no signup, no clutter.

Open the Median Calculator

Contact Us