"> Median Formula in Statistics: Examples & How to Calculate
Home > Library > Statistics > Median Formula in Statistics: Definition, Examples & How to Calculate

Published by at September 21st, 2021 , Revised On June 16, 2026

The median is the middle value of a dataset once the numbers are arranged in order. To find it, sort your data from smallest to largest and apply the median position formula: the median sits at position (n + 1) ÷ 2, where n is the number of values. If n is odd, that position gives you a single middle value; if n is even, you take the average of the two middle values.

When working with data in statistics, one question comes up almost immediately: what does a “typical” value really look like? In the UK education system, from GCSE Maths to A‑level Statistics and university research, students are often taught that averages explain data. But not all averages tell the full story, and that is where the median becomes essential.

Unlike the mean, the median is not distorted by extremely high or low values — a common issue when analysing real‑world data such as household incomes, property prices, exam results, or medical studies. For this reason, the median is widely used by UK statisticians, researchers, and government bodies, including the Office for National Statistics, to present fair and realistic insights. This guide walks through the median formula, worked examples for both odd and even datasets, when to choose the median over the mean, and how it is used in research.

“The median is the value below which 50% of the data lie. It is a useful measure when a distribution is skewed or contains outliers, because it is not affected by extreme values.” — Office for National Statistics, Statistical literacy guidance

What Is the Median?

The median is the middle value in a dataset when all observations are arranged in ascending (or descending) order. Exactly half the values in the dataset fall below the median and half fall above it. It is a measure of central tendency that describes the typical or central value but, unlike the mean, it is not pulled by extreme values at either end of the distribution.

The median is one of three main measures of central tendency, alongside the mean and the mode. Each summarises a dataset with a single representative number, but they answer slightly different questions:

  • Mean: the arithmetic average — add every value and divide by the count.
  • Median: the middle value of the ordered data — the focus of this guide.
  • Mode: the value that occurs most frequently.

Because the median depends only on the rank (position) of values rather than their magnitude, it is described as a robust or resistant statistic — it stays stable even when a dataset contains outliers.

Looking for statistical analysis help?

ResearchProspect to the rescue!

Our expert statisticians can calculate, interpret and report the right measures of central tendency for your dataset — try our statistical analysis service and present your data with confidence.

The Median Formula & How To Calculate It

There is no single arithmetic formula for the median in the way there is for the mean. Instead, you use a position formula to locate the middle value within the ordered data. Follow these three steps.

Step 1: Sort Your Data

Arrange all values from smallest to largest. This step is non‑negotiable — skipping it will almost always give you the wrong answer.

Step 2: Apply the Median Position Formula

Count the number of values, n, and find the median’s position:

Median position = (n + 1) ÷ 2
  • Odd number of values: (n + 1) ÷ 2 lands exactly on one observation — that value is the median.
  • Even number of values: (n + 1) ÷ 2 lands halfway between two observations. Take the two middle values — at positions n ÷ 2 and (n ÷ 2) + 1 — and average them.

Step 3: Read Off (or Average) the Middle Value

Identify the value at the calculated position. For an even dataset, add the two middle values and divide by two. The table below shows the formula applied to three datasets.

37121820median = middle value (orange)
The median is the middle value once the data are ordered.
Ordered Dataset n Step (Position Formula) Median
12, 15, 18, 22, 27 5 (odd) Position = (5 + 1) ÷ 2 = 3rd value 18
12, 15, 18, 22, 27, 31 6 (even) Average of 3rd & 4th values = (18 + 22) ÷ 2 20
4, 7, 9, 11, 14, 17, 19, 24 8 (even) Average of 4th & 5th values = (11 + 14) ÷ 2 12.5
Worked Example — Odd Dataset: A class scores 12, 27, 18, 15, 22 on a quiz. Sort: 12, 15, 18, 22, 27. Here n = 5, so the median position is (5 + 1) ÷ 2 = 3. The 3rd value is 18, so the median score is 18.
Worked Example — Even Dataset: Six daily temperatures (°C) are recorded: 12, 15, 18, 22, 27, 31 (already sorted). Here n = 6, so (6 + 1) ÷ 2 = 3.5 — the median lies between the 3rd value (18) and the 4th value (22). Averaging them: (18 + 22) ÷ 2 = 20°C.
Example — Why the Median Matters: A study records waiting times (in minutes) for patients at 7 NHS walk‑in centres: 8, 12, 14, 19, 23, 35, 74. Sorted in order with n = 7, the median is at position (7 + 1) ÷ 2 = 4 — the 4th value, 19 minutes. The mean is (8 + 12 + 14 + 19 + 23 + 35 + 74) ÷ 7 = 185 ÷ 7 ≈ 26.4 minutes. The single centre with a 74‑minute wait pulls the mean well above what most patients actually experienced, so the median of 19 minutes is the more representative figure.

Why The Median Is Preferred For Skewed Data

When data is normally distributed, the mean, median and mode are all approximately equal, and the mean works perfectly well. But most real‑world data is not symmetrical. Income, house prices, hospital waiting times and scores on easy tests all tend to be skewed, and in skewed distributions the mean gets dragged towards the long tail.

Distribution Type Relationship When To Use The Median
Symmetric (normal) Mean ≈ Median ≈ Mode Not essential, but harmless
Positive skew (right tail) Mean > Median > Mode Recommended — the mean is inflated by high outliers
Negative skew (left tail) Mean < Median < Mode Recommended — the mean is deflated by low outliers

Median Vs Mean: Which Should You Use?

Here is the key distinction: the mean treats every value as equally important and uses every value’s magnitude, so a single extreme value can swing it significantly. The median depends only on rank, so an outlier barely moves it. A quick comparison:

Feature Mean Median
What it measures Arithmetic average of all values Middle value of ordered data
Affected by outliers? Yes — sensitive No — resistant/robust
Best for Symmetric data with no extreme values Skewed data or data with outliers
Data type required Interval or ratio Ordinal, interval or ratio
Uses every value’s size? Yes No — only its rank

Real‑world examples where the median is the fairer summary:

  • UK house prices: The median house price in England was around £290,000 in 2023 (ONS), while the mean is substantially higher because multi‑million‑pound properties in London and the South East drag the average upwards.
  • NHS waiting times: The median wait for a first outpatient appointment gives a clearer picture of the typical patient’s experience than a mean inflated by a small number of very long waits.
  • Student essay grades: If most students score 55–68 and one scores 22, the median is more representative of what the class achieved.

The Median & Levels Of Measurement

The median requires that you can order your data, so it is appropriate for ordinal, interval and ratio data. It is not appropriate for nominal data (unordered categories such as eye colour or nationality), where the mode is the only valid measure of central tendency.

The Median & Measures Of Spread

When you report the median, always pair it with the interquartile range (IQR) — the range covering the middle 50% of the data. The IQR is to the median what the standard deviation is to the mean: it tells your reader how spread out the data is around the central value. You can read more in our guide to the interquartile range and to measures of variability.

Student Tip: In your dissertation, if your data is skewed, report both the mean and the median and explain why you are using the median as your primary measure. Showing that you have checked the distribution and chosen accordingly demonstrates statistical competence that will strengthen your methodology chapter. See our wider guide to descriptive statistics for how to present these alongside one another.

Median In Inferential Statistics

The median is the basis in inferential statistics for several important non‑parametric statistical tests — tests used when data does not meet the assumptions of parametric methods. The Mann‑Whitney U, Wilcoxon signed‑rank and Kruskal‑Wallis tests all work with ranked data and are appropriate when your outcome variable is ordinal or skewed. Choosing a median‑based test in these situations protects your conclusions from being distorted by outliers.

Frequently Asked Questions

What is the formula for the median?

First sort your data from smallest to largest, then locate the middle using the position formula: median position = (n + 1) ÷ 2, where n is the number of values. If n is odd, that position gives a single median value. If n is even, average the two middle values at positions n ÷ 2 and (n ÷ 2) + 1.

Sort the data, then take the two middle values and average them. For example, for 12, 15, 18, 22, 27, 31 (n = 6) the two middle values are the 3rd and 4th: (18 + 22) ÷ 2 = 20.

In maths, the median is the middle value of a list of numbers arranged in order. Exactly half the values are smaller than the median and half are larger, which makes it a measure of the centre of a dataset.

Yes. The median depends only on the rank of values, not their magnitude, so adding or changing an extreme value barely shifts it. This is why the median is preferred over the mean for skewed data such as incomes and house prices.

The mean is the arithmetic average — add all values and divide by the count — and is affected by outliers. The median is the middle value of the ordered data and is resistant to outliers. For symmetric data they are similar; for skewed data the median is usually more representative.

Use the median when your data is skewed, contains outliers, or is ordinal. Use the mean when the data is roughly symmetric and free of extreme values. When in doubt, report both and explain your choice.

About Carmen Troy

Avatar for Carmen TroyTroy has been the leading content creator for ResearchProspect since 2017. He loves to write about the different types of data collection and data analysis methods used in research.

WhatsApp Live Chat