IQR Stats- Measuring Data Spread
What Is IQR and Why You Should Care
The Interquartile Range (IQR) tells you where the middle 50% of your data lives. It's the distance between the 25th percentile (Q1) and the 75th percentile (Q3).
Unlike range or standard deviation, IQR ignores outliers completely. That's not a bug—it's the feature. When your data has extreme values, IQR gives you the real story about typical performance.
How to Calculate IQR
Here's the formula:
IQR = Q3 - Q1
That's it. But you need to find Q1 and Q3 first.
Step-by-Step Process
- Sort your data from smallest to largest
- Find the median (Q2)—this splits your data in half
- Find the median of the lower half → Q1
- Find the median of the upper half → Q3
- Subtract: Q3 minus Q1
Example Calculation
Data set: 2, 4, 6, 8, 10, 12, 14, 16, 18
- Median (Q2) = 10
- Lower half: 2, 4, 6, 8 → Q1 = 5
- Upper half: 12, 14, 16, 18 → Q3 = 15
- IQR = 15 - 5 = 10
The middle 50% of values span 10 units.
IQR vs. Other Spread Measures
Here's how IQR stacks up against the alternatives:
| Measure | Outlier Resistant | Uses All Data | Ease of Calculation |
|---|---|---|---|
| IQR | Yes ✓ | No | Medium |
| Standard Deviation | No ✗ | Yes | Medium |
| Range | No ✗ | No | Easy |
| Variance | No ✗ | Yes | Hard |
Standard deviation gets wrecked by outliers. One extreme value can blow up your entire measure. IQR shrugs it off.
Finding Outliers with IQR
This is where IQR earns its keep. Use it to identify values that don't belong:
- Lower bound: Q1 - 1.5 × IQR
- Upper bound: Q3 + 1.5 × IQR
Anything below the lower bound or above the upper bound is a potential outlier.
Quick Example
If Q1 = 20, Q3 = 40, and IQR = 20:
- Lower bound: 20 - (1.5 × 20) = -10
- Upper bound: 40 + (1.5 × 20) = 70
Values below -10 or above 70 are outliers. In most real data, negative values don't make sense anyway, so you'd flag anything above 70.
Reading Box Plots
Box plots visualize IQR directly. Here's what you're looking at:
- Left whisker: Lowest value within lower bound
- Box left edge: Q1
- Line in box: Median (Q2)
- Box right edge: Q3
- Right whisker: Highest value within upper bound
- Dots outside: Outliers
📊 The box IS the IQR. The longer the box, the more spread in your middle data.
When to Use IQR
IQR works best when:
- Your data has outliers or is skewed
- You're comparing distributions with different shapes
- You need a quick outlier check
- You're working with ordinal data or small samples
IQR is the standard choice in exploratory data analysis. It's robust, which means your conclusions hold up even when data misbehaves.
Common Mistakes to Avoid
- Don't use IQR with normally distributed data—standard deviation is better there
- Don't forget to sort first—IQR calculations require ordered data
- Don't assume outliers are errors—IQR flags them, but you still need to investigate
- Don't use IQR with very small samples—you need enough data to have meaningful quartiles
Practical Applications
You'll see IQR used in:
- Salary data—outliers (CEOs, entry-level interns) skew the mean, but IQR shows the real spread
- Housing prices—a few mansions ruin the average; IQR handles it
- Test scores—identify students who need help without being thrown off by perfect scores
- Medical data—patient age ranges, recovery times, vital signs
How to Get Started
You can calculate IQR manually, or use built-in functions:
- Excel:
=QUARTILE(data, 3) - QUARTILE(data, 1) - Python (NumPy):
from numpy import percentile; iqr = percentile(data, 75) - percentile(data, 25) - R:
IQR(data) - Google Sheets:
=QUARTILE(data, 3) - QUARTILE(data, 1)
Pick your tool and start. For small datasets, do it by hand once so you understand what the software is doing.
The Bottom Line
IQR tells you about typical spread, not total spread. It's resistant to outliers, easy to calculate, and works with any dataset that can be ordered.
Use it when you want honest answers about where your data actually lives—not distorted by extremes.