What is the interquartile range?
The interquartile range, or IQR, is Q3 minus Q1. It measures the distance between the first and third quartiles, describing the spread of the middle portion of an ordered dataset. Because it uses quartiles rather than only the minimum and maximum, it is usually less sensitive to extreme observations than the full range.
The calculator above starts with raw observations. It sorts them numerically, finds Q1 and Q3 using the quartile method you select, then applies IQR = Q3 − Q1. It also reports the median, the observed minimum and maximum, a five-number summary, and the standard 1.5 × IQR fences used to flag potential outliers.
IQR formula and outlier fences
IQR formula
IQR = Q3 − Q1
Q1 = first quartile
Q3 = third quartile
1.5 × IQR rule
Lower fence = Q1 − 1.5 × IQR
Upper fence = Q3 + 1.5 × IQR
Flag x when:
x < lower fence
or x > upper fence
The fence values are cutoffs, not observations. The boxplot produced by this page uses observed whisker endpoints: the lower whisker is the smallest observed value at or above the lower fence, and the upper whisker is the largest observed value at or below the upper fence. Observations past those endpoints are drawn separately.
How to calculate IQR from a dataset
- Sort the observations from smallest to largest.
- Find the median, also called Q2.
- Find Q1 and Q3 using the quartile convention required for your work.
- Subtract Q1 from Q3.
- If you need outlier screening, calculate the lower and upper 1.5 × IQR fences.
- Inspect observations beyond those fences. Treat the rule as a flag for review, not an instruction to delete data.
Why Q1 and Q3 can differ between calculators
There is no single computational convention used everywhere for sample quartiles. One course may define Q1 as the median of the lower half after excluding the overall median. Another may include the overall median in both halves. Statistical software often treats quartiles as sample percentiles and interpolates between ordered observations.
Exclusive median of halves
For odd n, the overall median belongs to neither half. The default calculator option uses this convention because it is common in introductory hand calculations.
Inclusive median of halves
For odd n, the overall median is included at the end of the lower half and the start of the upper half. Q1 and Q3 can shift on small datasets.
Type 7 linear interpolation
Quartiles are calculated as interpolated percentiles. R uses type 7 by default, and NumPy uses a linear method equivalent to type 7 by default.
Microsoft Excel also exposes separate QUARTILE.INC and QUARTILE.EXC functions. That is a practical reminder that software can offer more than one quartile rule. If you need to reproduce an official answer, use the same function or convention as the source you are matching.
Worked IQR example
Use the dataset 2, 4, 5, 7, 8, 10, 12, 14. It is already sorted and contains eight observations, so the exclusive and inclusive median-of-halves methods agree.
Find the quartiles
Median = (7 + 8) / 2 = 7.5
Lower half: 2, 4, 5, 7
Q1 = (4 + 5) / 2 = 4.5
Upper half: 8, 10, 12, 14
Q3 = (10 + 12) / 2 = 11
Find the IQR
IQR = Q3 − Q1
IQR = 11 − 4.5
IQR = 6.5
Lower fence = 4.5 − 1.5(6.5) = −5.25
Upper fence = 11 + 1.5(6.5) = 20.75
No observation lies below −5.25 or above 20.75, so this dataset has no values flagged by the 1.5 × IQR rule.
Outlier example using the IQR rule
Consider 1, 2, 3, 4, 5, 6, 7, 30 under the exclusive median-of-halves method. Q1 is 2.5 and Q3 is 6.5, giving an IQR of 4. The lower fence is −3.5 and the upper fence is 12.5. The value 30 is above the upper fence, so it is flagged as a potential outlier.
That flag does not prove that 30 is incorrect. It may be a valid but unusual observation, a measurement issue, a data-entry problem, or a meaningful feature of the process that produced the data. Check the context before deciding what to do with it.
IQR, range and standard deviation
| Measure | What it uses | What it describes | Sensitivity to extremes |
|---|---|---|---|
| IQR | Q1 and Q3 | Spread between the first and third quartiles | Usually more resistant than the full range |
| Range | Minimum and maximum | Full observed span | Highly sensitive to an extreme endpoint |
| Standard deviation | Distances from the mean | Average scale of dispersion around the mean | Can change substantially when extreme values move |
If your goal is to summarize a skewed dataset or examine possible outliers, the IQR is often useful alongside the median. If your analysis assumes a roughly symmetric distribution and the mean is the center of interest, standard deviation may be more informative. The measures answer different questions, so one should not be treated as a universal replacement for the others.
How the IQR relates to a boxplot
In a standard quartile box, the left or lower edge represents Q1, the line inside the box marks the median, and the right or upper edge represents Q3. The width of that box on the data scale is the IQR. When 1.5 × IQR fences are used, whiskers typically extend to the most extreme observed values still inside the fences. Observations beyond the whiskers are drawn separately.
The calculator follows that rule for its dynamic boxplot. It does not draw whiskers directly to the numerical fence values because a fence is a threshold, not necessarily a value that appears in the dataset.
Related statistics pages
The calculator is part of the site’s descriptive statistics material. Use these pages when you need the concept behind a result or a companion calculation.
Sources and method references
- National Institute of Standards and Technology. What are outliers in the data? Covers quartiles, IQR fences and boxplot outlier screening.
- Microsoft Support. QUARTILE.INC and QUARTILE.EXC.
- R documentation. Sample quantiles, including the type parameter and the type 7 default.
- NumPy documentation. numpy.quantile, including the default linear method and alternative quantile estimators.
Frequently asked questions
The IQR formula is IQR = Q3 − Q1. Q1 is the first quartile and Q3 is the third quartile. The result measures the distance between those quartiles and describes the spread of the middle portion of the ordered data under the quartile convention you are using.
Sort the data, find Q1 and Q3 using a stated quartile convention, then subtract Q1 from Q3. For example, if Q1 = 12 and Q3 = 21, the IQR is 21 − 12 = 9. The calculator also shows how the dataset was split or interpolated.
One common hand-calculation method sorts the data, finds the overall median, then takes the median of the lower half as Q1 and the median of the upper half as Q3. For odd-sized datasets, you must state whether the overall median is excluded from or included in those halves.
Calculate the lower fence as Q1 − 1.5 × IQR and the upper fence as Q3 + 1.5 × IQR. An observation below the lower fence or above the upper fence is flagged as a potential outlier. Values exactly equal to a fence are not beyond the fence.
The IQR measures the distance from the first quartile to the third quartile. It is a measure of spread focused on the central portion of the distribution. A larger IQR means Q1 and Q3 are farther apart; a smaller IQR means they are closer together.
Different calculators may use different quartile conventions. Differences often appear with odd-sized or small datasets, or when one tool uses median-of-halves and another uses percentile interpolation. Compare the quartile method before comparing the final IQR.
No. Under a valid ordered quartile calculation, Q3 is not less than Q1, so Q3 − Q1 is nonnegative. The IQR can be zero when Q1 and Q3 are equal.
The IQR is generally more resistant to extreme values than the full range because it depends on quartiles rather than only the minimum and maximum. It is not completely immune to changes in the data, though. Moving or adding observations can shift Q1 or Q3 in some datasets.
The range is maximum minus minimum, so it uses the two endpoints of the dataset. The IQR is Q3 minus Q1, so it focuses on the central portion. A single extreme endpoint can change the range sharply while leaving the IQR unchanged or changing it much less.
The five-number summary is the minimum, Q1, median, Q3 and maximum. It provides a compact description of location and spread and supplies the core values used to draw a basic boxplot. The calculator reports all five values after each calculation.