How do you find the IQR of a data set? But the interquartile range (IQR) is a fundamental measure of statistical dispersion that tells you how spread out the middle 50 % of your data are. Which means unlike the range, which can be heavily influenced by outliers, the IQR focuses on the central portion of the distribution, making it a strong descriptor for skewed data or data sets with extreme values. In this guide you will learn the concept behind quartiles, a step‑by‑step manual method for calculating the IQR, practical examples, and how to obtain the same result quickly with common tools such as Excel, Python, and R. By the end, you’ll be able to compute and interpret the IQR confidently for any numerical data set.
Understanding Quartiles and the IQR
Before diving into calculations, it helps to clarify what quartiles are. When a data set is ordered from smallest to largest, three values split the data into four equal parts:
- Q1 (first quartile) – the median of the lower half of the data (the 25th percentile).
- Q2 (second quartile) – the overall median of the data set (the 50th percentile).
- Q3 (third quartile) – the median of the upper half of the data (the 75th percentile).
The interquartile range is simply the difference between Q3 and Q1:
[ \text{IQR} = Q3 - Q1 ]
Because it uses only the middle 50 % of observations, the IQR is less sensitive to extreme values than the standard deviation or the overall range. Even so, g. It is also the building block for box‑plot whiskers and outlier detection rules (e.5·IQR or above Q3 + 1.Consider this: , any point below Q1 − 1. 5·IQR is often flagged as an outlier).
Not the most exciting part, but easily the most useful.
Step‑by‑Step Manual Calculation
Finding the IQR by hand follows a clear, repeatable process. Below is a numbered list that works for both odd‑ and even‑sized data sets The details matter here..
- Sort the data in ascending order.
- Find the median (Q2).
- If the number of observations n is odd, the median is the middle value.
- If n is even, the median is the average of the two central values.
- Split the data into two halves around the median.
- For an odd n, exclude the median itself when forming the lower and upper halves.
- For an even n, simply take the first n/2 values as the lower half and the last n/2 values as the upper half.
- Calculate Q1 as the median of the lower half.
- Calculate Q3 as the median of the upper half.
- Subtract Q1 from Q3 to obtain the IQR.
Why the Median‑Exclusion Rule Matters
When n is odd, the median belongs to neither half; otherwise each half would contain the median twice, biasing Q1 and Q3 toward the center. This rule ensures that each quartile truly represents the 25th and 75th percentiles.
Worked Example
Consider the following data set of 11 exam scores (already sorted):
55, 58, 60, 62, 65, 68, 70, 72, 75, 80, 85
- Median (Q2) – With 11 values, the middle is the 6th value: 68.
- Lower half (values below 68): 55, 58, 60, 62, 65.
- Median of lower half = 3rd value → Q1 = 60.
- Upper half (values above 68): 70, 72, 75, 80, 85.
- Median of upper half = 3rd value → Q3 = 75.
- IQR = 75 − 60 = 15.
Thus, the middle 50 % of scores lie within a 15‑point band.
Even‑Sized Example
Now take a data set with 10 numbers:
12, 15, 18, 22, 24, 27, 30, 33, 37, 40
- Median (Q2) – Average of 5th and 6th values: (24 + 27)/2 = 25.5.
- Lower half (first 5 values): 12, 15, 18, 22, 24 → median = 18 → Q1 = 18.
- Upper half (last 5 values): 27, 30, 33, 37, 40 → median = 33 → Q3 = 33.
- IQR = 33 − 18 = 15.
Notice that the IQR is the same as in the odd‑sized example, illustrating how the measure captures spread independently of the exact median Still holds up..
Using Software to Compute the IQR
While manual calculation is instructive, real‑world data sets often contain hundreds or thousands of observations. The following snippets show how to obtain the IQR quickly in three popular environments Which is the point..
Excel
- Enter your data in a column (e.g., A2:A101).
- Use the
QUARTILE.EXCorQUARTILE.INCfunction:=QUARTILE.INC(A2:A101,1)returns Q1.=QUARTILE.INC(A2:A101,3)returns Q3.
- Compute IQR:
=QUARTILE.INC(A2:A101,3)-QUARTILE.INC(A2:A101,1).
Tip: QUARTILE.EXC excludes the median when n is even, matching the manual method described above; QUARTILE.INC includes it. Choose the version that aligns with your definition Simple, but easy to overlook..
Python (with pandas)
import pandas as pd
# Sample data
data = pd.Series([55,58,60,62,65,68,70,72,75,80,85])
q1 = data.quantile(0.25)
q3 = data.quantile(0.75
```python
# Continue the Python example
iqr = q3 - q1
print(f"Q1 = {q1}, Q3 = {q3}, IQR = {iqr}")
# If you prefer a one‑liner with NumPy
import numpy as np
arr = np.array([55,58,60,62,65,68,70,72,75,80,85])
q1_np = np.percentile(arr, 25)
q3_np = np.percentile(arr, 75)
iqr_np = q3_np - q1_np
print(f"NumPy → Q1 = {q1_np}, Q3 = {q3_np}, IQR = {iqr_np}")
R
scores <- c(55, 58, 60, 62, 65, 68, 70, 72, 75, 80, 85)
iqr_val <- IQR(scores) # uses the default type‑7 quantile definition
summary <- summary(scores) # shows the quartiles as well
cat("Q1 =", summary[2], "\n")
cat("Q3 =", summary[4], "\n")
cat("IQR =", iqr_val, "\n")
Interpreting the IQR
The inter‑quartile range tells you how spread out the central half of your data is. Because it is based on the median and its surrounding points, the IQR is reliable—it isn’t swayed by extreme values or outliers the way the full range would be.
A common rule for spotting potential outliers is the 1.5 × IQR rule:
- Lower fence = Q1 − 1.5·IQR
- Upper fence = Q3 + 1.5·IQR
Any observation below the lower fence or above the upper fence is flagged as an outlier. This approach is widely used in box‑plot construction and in exploratory data analysis.
When to Prefer the IQR Over Other Spread Measures
| Measure | Sensitivity to Outliers | What It Describes |
|---|---|---|
| Range | Very high | Entire data span |
| Variance / Std. Dev. | High (depends on squaring) | Overall dispersion |
| IQR | Low (ignores extremes) | Middle 50 % spread |
If your goal is to understand the typical variability of a process while ignoring rare spikes, the IQR is the most informative metric.
Conclusion
Calculating the inter‑quartile range is a straightforward yet powerful way to quantify the spread of the central portion of a data set. By splitting the ordered data at the median, taking the medians of the lower and upper halves, and subtracting them, you obtain a measure that is both intuitive and resistant to extreme values. Whether you perform the calculation by hand, in Excel, Python, or R, the steps remain the same, and the result provides a clear picture of the data’s core variability—making the IQR an essential tool in any statistician’s or data analyst’s toolkit.