How to Calculate the Median: Middle Ranks, Ties, and Ordinal Data
Learn how to find the median for odd and even numeric data, retain ties, handle ordinal responses, and report what this rank-based center does and does not show.
The median is the value or position in the middle after observations are sorted from smallest to largest. Unlike the arithmetic mean, which is pulled by the magnitude of every value, the median is usually less sensitive to how large an extreme value is. But one median cannot show a distribution’s shape or total spread. To use it well, first sort the observations, check whether there is one central rank or two, and identify the measurement scale.
The middle rank determines the median
Sort the observations in ascending order without collapsing duplicates, and let n be the number of observations. If n is odd, the median is the value at position (n+1)/2. For example, the middle of 5, 8, 11, 20, 40 is the third value, 11. If n is even and the data are numeric, find the values at positions n/2 and n/2+1, then take their arithmetic mean. Consider this hypothetical set of work-processing times in minutes: 12, 15, 16, 18, 19, 23. There are six observations, so the third and fourth values, 16 and 18, are in the middle. The median is (16+18)/2 = 17 minutes. The value 17 need not be one of the observations. Finding the position and calculating the median value are separate steps. OpenStax explains the rank rule for odd and even data and the midpoint calculation for an even number of observations: https://openstax.org/books/introductory-statistics-2e/pages/2-5-measures-of-the-center-of-the-data. The median is also called the second quartile (Q2) or 50th percentile; quartiles and percentiles are likewise found from ordered data: https://openstax.org/books/introductory-statistics-2e/pages/2-3-measures-of-the-location-of-the-data.
Count every repeated observation. In 2, 2, 4, 7, 9, the two 2s are not collapsed into one distinct value, so the third observation, 4, is the median. If you have only a frequency table, add frequencies cumulatively to find which value contains the central rank. With grouped intervals, you may identify the interval containing the median, but you cannot recover the exact median of the raw observations. An interpolation that assumes values are evenly spread inside an interval is an estimate based on that assumption, not the exact raw-data median.
The median divides ranks; it does not describe the whole distribution
For numeric data, a median M is a value with at least half of the observations at or below it and at least half at or above it. When the central value is tied, it is not necessary for exactly half the observations to be strictly below and half strictly above. With an even number of numeric observations, the calculated median can also fall between the two central observations. OpenStax describes the median as dividing ordered data into lower and upper halves and notes that it need not itself be observed: https://openstax.org/books/introductory-statistics-2e/pages/2-3-measures-of-the-location-of-the-data.
Because it is based on rank, the median may stay the same when the magnitude of the largest or smallest observation changes, as long as those values do not cross the central ranks. It can still change when values near the middle change or when enough observations move. “Resistant to outliers” means less sensitive to the magnitude of extreme values; it does not mean that every unusual value or data error can be ignored. Check the range and data context, and do not delete a large value unless you have verified it is an error.
A single median does not reveal two separate clusters, gaps, a long tail, or a subgroup. Two groups can have the same median but very different spreads and shapes. Pair the median with the interquartile range (IQR) when you need to describe the spread of the middle half, and inspect a suitable distribution plot when shape matters. NIST’s discussion of measures of location compares mean, median, and mode across distributions: https://itl.nist.gov/div898/handbook/eda/section3/eda351.htm.
Do not apply the same calculation to numeric codes and categories
There is no median for nominal categories without an order, such as red, blue, and green. Ordinal responses can be ranked, so a middle response category can be identified, but coding “very dissatisfied, dissatisfied, neutral, satisfied, very satisfied” as 1 through 5 does not make the gaps between categories equal. If there are an even number of responses, do not interpret the arithmetic average of the two central category codes as if it were an actual response. Report both central categories, or state in advance the rule used to select one category when a single label is necessary. OpenStax explains that ordinal values can be ordered but their differences cannot be measured: https://openstax.org/books/introductory-statistics-2e/pages/1-3-frequency-frequency-tables-and-levels-of-measurement.
When should you choose the median, and what else should you report?
The median can be a useful summary of the center when a distribution is skewed or a few large values differ greatly in magnitude from typical observations. If the question is how long a typical delivery takes, the median delivery time may be informative. If the decision concerns total cost or average resource use per item, the arithmetic mean may answer more directly because it reflects every numeric magnitude. NIST notes that the median can represent location better than the mean for data with extreme tails, while also cautioning that the most meaningful measure depends on the distribution and purpose: https://itl.nist.gov/div898/handbook/eda/section3/eda351.htm.
In a practical report, give more than the median: include the number of valid observations, the unit, the population or period being described, and how missing values were handled. Hypothetical example wording: “The median processing time was 17 minutes across 240 orders. We used the 228 orders with a recorded time and excluded 12 with no recorded time.” A median calculated from a sample describes that sample. Whether the sample represents the population of interest depends on the sampling and data-collection process.
For a broader guide to choosing center, spread, and distribution summaries, see the descriptive statistics guide: https://knowledge.linkspot.net/en/articles/8293b6d7-aa04-4a04-a0de-dc704dc46ac8.