The interquartile range (IQR) measures the spread of the middle 50% of a dataset by subtracting the first quartile (Q1) from the third quartile (Q3). It's a solid statistic used to identify outliers and assess data dispersion without being influenced by extreme values.
IQR is calculated as Q3 − Q1. This value represents the range within which the central half of the data lies. Unlike standard deviation, IQR is resistant to skew and outliers, making it ideal for skewed distributions or datasets with extreme values.
For example, in a set of test scores: 65, 70, 72, 75, 78, 80, 82, 85, 90, 95, 100, the median splits the data into two halves. The lower half (65, 70, 72, 75, 78) gives Q1 = 72. The upper half (82, 85, 90, 95, 100) gives Q3 = 90. Thus, IQR = 90 − 72 = 18.
IQR isolates the core of a dataset by focusing on the middle 50%. It ignores the lowest 25% and highest 25%, reducing the impact of anomalies. This makes it especially useful in exploratory data analysis and quality control.
Statistical software like R and Python's pandas library compute IQR automatically. In Python, using pandas.DataFrame.quantile(), you can extract Q1 and Q3 with df['column'].quantile(0.25) and df['column'].quantile(0.75), then subtract them.
According to the American Statistical Association, IQR is preferred over range and variance in non-normal distributions because it reflects central tendency better under skewness. The National Institute of Standards and Technology (NIST) also recommends IQR for outlier detection in industrial quality metrics.
Follow these steps to compute IQR by hand:
Example: Dataset {12, 15, 18, 20, 22, 25, 28, 30, 33}. Sorted and median is 22. Lower half: {12, 15, 18, 20} → Q1 = (15 + 18)/2 = 16.5. Upper half: {25, 28, 30, 33} → Q3 = (28 + 30)/2 = 29. IQR = 29 − 16.5 = 12.5.
A common mistake is misidentifying the median position when the dataset size is odd. Always confirm whether the median is included in either half. Some methods exclude the median from both halves, leading to incorrect quartiles.
Many assume IQR equals the full range divided by two. That's false. IQR covers only the middle half, not the entire span. For example, a dataset with min=10, max=100, range=90, but IQR=20-no direct proportionality exists.
Another error is treating IQR as a measure of central tendency. It is not. IQR measures spread. Median describes center. Confusing the two leads to flawed interpretations. A high IQR indicates greater variability in the middle 50%, not higher average values.
Some think IQR applies only to continuous data. But it works equally well on discrete data-like counts of defective parts per batch. In manufacturing, IQR identifies consistent production levels versus abnormal spikes.
Outliers lie beyond the inner fences: Q1 − 1.5×IQR and Q3 + 1.5×IQR. Values outside these bounds are flagged as potential outliers.
Using the earlier example: Q1 = 72, Q3 = 90, IQR = 18. Inner fences: 72 − 27 = 45 and 90 + 27 = 117. Any score below 45 or above 117 is an outlier. In the dataset {65, 70, 72, 75, 78, 80, 82, 85, 90, 95, 100}, no values exceed 117, so no outliers exist.
If a student scored 40, it would fall below 45 and be marked as an outlier. This suggests either a data entry error or an unusual performance requiring investigation.
| Dataset | Q1 | Q3 | IQR | Outlier Boundaries |
|---|---|---|---|---|
| 65, 70, 72, 75, 78, 80, 82, 85, 90, 95, 100 | 72 | 90 | 18 | 45 to 117 |
| 12, 15, 18, 20, 22, 25, 28, 30, 33 | 16.5 | 29 | 12.5 | 3.75 to 47.75 |
When analyzing survey responses, IQR helps distinguish between typical answers and rare extremes. In a study of daily screen time among teens, a median of 4 hours, Q1=3, Q3=6, IQR=3. Any response above 10.5 hours (6 + 1.5×3) would be flagged for review.
In healthcare, IQR detects abnormal lab results. For example, blood glucose levels in a group of patients: Q1=90 mg/dL, Q3=110 mg/dL, IQR=20. A reading of 140 mg/dL exceeds the upper fence (110 + 30 = 140), triggering a follow-up.
In finance, IQR evaluates stock return volatility. A fund with returns: −5%, −2%, 0%, 3%, 5%, 7%, 10%. Q1=−2%, Q3=7%, IQR=9%. Returns outside −15.5% to 20.5% may indicate risk exposure.
During a project analyzing student grades, I found that while the average was 78, the IQR was only 12. This suggested most students clustered tightly around the median, but a few low scores pulled the mean down. Using IQR helped confirm that the distribution wasn't symmetric.
Understanding how to find the iqr allows deeper insight into data structure. It's not just a calculation-it's a diagnostic tool. health metrics, IQR reveals patterns hidden in raw numbers.