ThisCalculator

Statistics

Calculating the Median: Formula, Steps, and Examples

Updated · Standard formula, shown below

The calculator for this page is switched off while it is checked. The formula is below, and the worked example in the article shows how to use it by hand.

Calculating the Median: Formula, Steps, and Examples

To calculate the median, put the numbers in order and find the middle value; if there are an even number of values, average the two middle values. Enter a comma-separated list of numbers to get the median, along with the count and the ordered middle value or pair used to find it.

Formula

First sort the data from smallest to largest. Let n be the number of values and let x(i) mean the value in position i after sorting.

  • If n is odd, the median is x((n + 1) / 2), the single middle value.
  • If n is even, the median is [x(n / 2) + x(n / 2 + 1)] / 2, the arithmetic mean of the two middle values.

The median and input values have the same unit, if any: for example, a data set of lengths in centimetres has a median in centimetres. The count n has no unit. The calculator displays the median to two decimal places, so its displayed value may be rounded; calculations use the entered numbers.

Worked Example

Using the default list, 4, 8, 15, 16, 23, 42, the values are already in ascending order. There are six values, so the count is 6. Because six is even, take the third and fourth values: 15 and 16.

Median = (15 + 16) / 2 = 31 / 2 = 15.5. To two decimal places, the calculator shows 15.50. The median is 15.5 in the same unit as the data, or simply 15.5 for unitless numbers.

How to Calculate the Median by Hand

For a small list, calculation is straightforward:

  1. Write down every observation, including repeated values.
  2. Sort the observations from least to greatest. Do not rely on their original order.
  3. Count the observations.
  4. If the count is odd, select the value in the middle position. If it is even, add the two central values and divide by two.

For example, with 3, 10, 5, 8, 12, sort the values to get 3, 5, 8, 10, 12. There are five observations, so the third value, 8, is the median. With 3, 5, 8, 10, there are four observations, so the median is (5 + 8) / 2 = 6.5. The answer does not have to be one of the original observations.

What the Median Tells You

The median is a measure of the centre of a data set. Half the observations are at or below it and half are at or above it, with ties possible. It is useful when a typical middle value matters, especially when a few unusually high or low observations would pull the mean away from most of the data.

Consider the values 2, 3, 3, 4, 100. The median is 3, while the mean is 22.4. The outlier 100 raises the mean substantially but does not change the middle position. This is why median household income, property values, or waiting times are often described using a median: the measure can better represent a skewed distribution. It still does not describe every observation or show how widely values vary.

Median Compared with Mean and Mode

The median, mean, and mode answer different questions. The mean is the sum of the values divided by their count, so each value affects it. The mode is the most frequent value; a data set can have one mode, several modes, or no repeated value. The median depends on the ranked positions, not the size of every value.

For a roughly balanced data set without extreme values, the mean and median may be close. In skewed data, they can differ. Neither measure is automatically best: use the mean when the arithmetic average is meaningful and appropriate, the median when a central ranked value is more informative, and the mode when the most common category or value is the target. For categories with no natural order, a numerical median usually is not meaningful.

Common Mistakes and Limits

  • Skipping the sort: The middle item in the original sequence is not necessarily the median. Sort first.
  • Dropping duplicates: Repeated observations count. For 1, 2, 2, 9, the median is (2 + 2) / 2 = 2.
  • Choosing one middle value for an even count: Average the two central values; do not round to one of them.
  • Confusing median with mean: The median is based on rank, while the mean uses the sum.
  • Mixing units or formats: Convert values to a common unit before combining them. For example, do not sort a mixture of inches and centimetres as though the raw numbers shared a unit.

A median alone hides details about spread, clusters, and outliers. A data set with a median of 10 could have values tightly grouped near 10 or spread across a broad range. Pair the median with a range, quartiles, or a visual summary when those differences matter. For an empty list, there is no median; missing entries should not be silently treated as zero.

Frequently Asked Questions

How do you find the median of an even number of values?
Sort the values, identify the two in the middle, add them, and divide by two. The result can fall between observed values.

Does the median have to be a number in the data set?
No. With an even number of observations, averaging the middle pair can produce a value not present in the list, such as 6.5 from 5 and 8.

What happens if a data set has repeated values?
Include every occurrence when sorting and counting. Repetition affects the positions and therefore can affect the median.

Can you calculate a median from an unsorted list?
Yes, but you must first arrange its values from smallest to largest, or use a method or tool that does so internally. The original order does not determine the median.

What is the median of an empty data set?
It is undefined because there is no middle observation or middle pair to select.

Related

Formula used
list values | Numbers | 4, 8, 15, 16, 23, 42
out median | Median | - | median(values) | 2
out count | Number of values | - | count(values) | 0

Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.