Written and maintained by CASRAI Editorial Board
Last updated
The interquartile range (IQR) is not the median. The median is a single value that marks the centre of a data set; the IQR is a distance that measures how spread out the middle half of the data is. Reported together as “median and interquartile range,” they describe where the data sit and how widely they vary, without being pulled around by extreme values. This guide defines each, shows the arithmetic on a skewed data set, and explains how to read, report and compute the pair. For the quartile calculation itself, see CASRAI’s guide to the interquartile range and five-number summary.
Is the interquartile range the median?
No. The median is the second quartile (Q2), the value below which 50% of the observations fall. The interquartile range is the difference between the third and first quartiles, Q3 minus Q1, and so spans the middle 50% of the data. The median is a location on the scale; the IQR is a width. The median normally lies somewhere inside the interval from Q1 to Q3, but it is not equal to the IQR and the two are not interchangeable.
Is interquartile range the same as median?
No. If a variable is recorded in days, both are expressed in days, but the median answers “what is a typical value?” while the IQR answers “how far apart are the quartiles?” Two data sets can share a median and have very different IQRs, or share an IQR and have different medians. That is why they are usually reported as a pair: a measure of central tendency and a measure of spread.
Definition in one paragraph
The median is the middle value of an ordered data set; Minitab’s documentation identifies it as Q2, with 50% of the data less than or equal to it. The interquartile range is, in the words of the NIST/SEMATECH e-Handbook of Statistical Methods, “the difference (Q3 – Q1)”, where the quartiles are the 25th and 75th percentiles. Minitab describes the IQR as the distance between the first and third quartiles, spanning the middle 50% of the data. Because both rest on rank order rather than on sums of values, a few extreme observations barely move them.
Formula with every symbol explained
IQR = Q3 − Q1
- Q1: the lower (first) quartile, the 25th percentile.
- Q3: the upper (third) quartile, the 75th percentile.
- Median (Q2): the 50th percentile. It does not appear in the IQR formula, which is a common source of the confusion above, but it is what you report beside it.
Software does not agree on how to locate Q1 and Q3 when they fall between two observations. NIST’s handbook places the lower quartile at the .25(N+1)th ordered point and the upper at the .75(N+1)th, interpolating when needed. The R documentation for quantile() lists nine methods; the default is type 7 (position (k−1)/(n−1)), and type 6 (position k/(n+1)) is the one it says is used by Minitab and by SPSS. The median is the same under all of them; Q1, Q3 and therefore the IQR can differ.
Worked example with real numbers
Consider eleven hospital lengths of stay, in days, already sorted: 2, 3, 3, 4, 5, 6, 8, 11, 15, 22, 40 (n = 11). The data are right-skewed, with a long tail created by the 22 and the 40. (This data set is a teaching example, not data from a study.)
- Median. With n = 11 the middle value is the 6th ordered observation, so the median is 6.
- Quartiles, (N+1) method (NIST; R type 6; Minitab and SPSS). Q1 is at position .25 × 12 = 3, the 3rd value: 3. Q3 is at position .75 × 12 = 9, the 9th value: 15. IQR = 15 − 3 = 12.
- Quartiles, R type 7 (the R default). Q1 is at position 1 + .25 × 10 = 3.5, halfway between the 3rd and 4th values (3 and 4): 3.5. Q3 is at position 1 + .75 × 10 = 8.5, halfway between the 8th and 9th values (11 and 15): 13. IQR = 13 − 3.5 = 9.5.
Both methods give a median of 6; the IQR is 12 or 9.5 depending on the method. For comparison, the mean of these values is 119 / 11 = 10.8, almost double the median, because the tail drags it upward.
Interpretation: reading the median inside the IQR
Read the median against Q1 and Q3, not alone. In the example above (type 7), the median of 6 is 2.5 above Q1 (3.5) but 7 below Q3 (13). The median sits much nearer the lower quartile, which signals a right-skewed distribution. For a deeper treatment of that shape, see left-skewed versus right-skewed distributions.
| What you see | What it suggests |
|---|---|
| Median roughly midway between Q1 and Q3 | The middle half of the data is roughly symmetric around the median. |
| Median closer to Q1 than to Q3 | The upper half is more stretched out: a right-skewed pattern, as in the worked example. |
| Median closer to Q3 than to Q1 | The lower half is more stretched out: a left-skewed pattern. |
| Large IQR relative to the median | The middle 50% covers a wide range of values. |
Minitab states that “the median and interquartile range are a better measure of central tendency and spread for highly skewed data” than the mean and standard deviation. If your data are roughly symmetric, the standard deviation with the mean is the more usual pairing.
Assumptions and common mistakes
- Treating the IQR as a centre. The IQR is a width. Quote the median for the centre.
- Reporting the IQR as a single number only. A width of 9.5 does not say where the middle half sits. Give Q1 and Q3 as well (see the reporting section).
- Mixing quartile methods. Comparing an IQR from SPSS with one from R’s default can show a difference that is only the method, as the worked example shows (12 versus 9.5). State which one you used.
- Using the IQR on tiny samples. With very few observations, the quartile positions are so coarse that the IQR is determined by one or two values; check the sample size before leaning on it.
- Assuming the IQR flags outliers by itself. It resists extreme values but does not remove them. For handling outliers, see winsorizing versus trimming.
How to report median and interquartile range (APA-style example)
Report the median with the abbreviation Mdn, followed by the IQR. The pattern used in CASRAI’s descriptive statistics guide is “Mdn = 19.0, IQR = 14.5–26.0”: the median, then the two quartile endpoints as a range. Applied to the worked example:
Length of stay was right-skewed (Mdn = 6.0 days, IQR = 3.5–13.0, n = 11; quartiles by the R type 7 method).
Giving both endpoints tells the reader where the middle half of the data lies, which a bare width cannot. Naming the quartile method in the methods section or a note lets readers reproduce the figures in their own software.
How to calculate it in Excel, R or Python
Excel
=MEDIAN(A1:A11)
=QUARTILE.INC(A1:A11,3) - QUARTILE.INC(A1:A11,1)
Microsoft documents QUARTILE.EXC as returning quartiles “based on percentile values from 0 to 1, exclusive”, and it also provides an inclusive counterpart, so check which function your template or protocol specifies.
R
x <- c(2,3,3,4,5,6,8,11,15,22,40)
median(x) # 6
quantile(x, c(.25, .75)) # type 7 default: 3.5, 13
quantile(x, c(.25, .75), type = 6) # 3, 15 (Minitab/SPSS style)
Python
import numpy as np
x = [2,3,3,4,5,6,8,11,15,22,40]
np.median(x) # 6.0
q1, q3 = np.percentile(x, [25, 75]) # 3.5, 13.0
q1, q3 = np.percentile(x, [25, 75], method='weibull') # 3.0, 15.0
iqr = q3 - q1
The outputs shown in the comments were checked against the hand calculations above. For plotting the same quantities, see box plots in R.
FAQ
Is the interquartile range the median?
No. The median is the 50th percentile (Q2). The IQR is Q3 minus Q1, the width of the middle 50% of the data.
Is interquartile range the same as median?
No. One is a distance and the other a location. Report both when you want to describe centre and spread without relying on the mean and standard deviation.
When should I report median and interquartile range instead of mean and standard deviation?
Minitab’s guidance is that the median and IQR are better measures of centre and spread for highly skewed data. If the data are close to symmetric, the mean and standard deviation are the conventional choice.
Can the median be outside the IQR?
No. The median is the 50th percentile, which lies between the 25th (Q1) and the 75th (Q3) percentiles, so it falls inside the interval from Q1 to Q3.
Why does my IQR differ between software packages?
Packages use different quartile definitions. The R documentation says its default is type 7 and that type 6 is used by Minitab and SPSS. The median is unaffected.
Sources
- NIST/SEMATECH e-Handbook of Statistical Methods, “Percentiles”: https://www.itl.nist.gov/div898/handbook/prc/section1/prc16.htm (checked 2026-10-29).
- R Documentation,
quantile(stats package): https://stat.ethz.ch/R-manual/R-devel/library/stats/html/quantile.html (checked 2026-10-29). - Minitab Support, “What are quartiles?”: https://support.minitab.com/en-us/minitab/help-and-how-to/graphs/boxplot/interpret-the-results/quartiles/ (checked 2026-10-29).
- Microsoft Support, QUARTILE.EXC function: https://support.microsoft.com/en-us/office/quartile-exc-function-5a355b7a-840b-4a01-b0f1-f538c2864cad (checked 2026-10-29).








