Calculate IQR- Interquartile Range Guide
What the Heck Is IQR and Why Should You Care?
Interquartile Range (IQR) is simply the spread of the middle 50% of your data. You get it by subtracting the first quartile from the third quartile. That's it. Nothing fancy.
You use IQR to understand how spread out your data is without getting fooled by extreme outliers. Unlike range (which uses min and max), IQR ignores the top 25% and bottom 25% of values. This makes it useful when you're dealing with real-world data that often has weird outliers.
The Three Quartiles You Need to Know
Before you calculate anything, you need to understand the three numbers that make up IQR:
- Q1 (First Quartile) — The median of the lower half of your data. 25% of values fall below this point.
- Q2 (Second Quartile / Median) — The middle value of your entire dataset. 50% fall below, 50% above.
- Q3 (Third Quartile) — The median of the upper half. 75% of values fall below this point.
IQR = Q3 - Q1
How to Calculate IQR in 5 Steps
Here's the actual process. No fluff.
Step 1: Sort Your Data
Arrange all values from smallest to largest. This is mandatory. Skipping this step is the most common reason people get wrong answers.
Step 2: Find the Median (Q2)
Locate the middle value. If you have an odd number of data points, that's the exact middle. If you have an even number, average the two middle values.
Step 3: Split Into Halves
Divide your sorted data into two halves at the median. Include the median in both halves if you had an odd number of points. Exclude it if you had an even number.
Step 4: Find Q1 and Q3
Calculate the median of each half. The lower half's median is Q1. The upper half's median is Q3.
Step 5: Subtract
IQR = Q3 - Q1
Real Example: Test Scores
Let's say you have these 9 test scores:
72, 85, 90, 95, 98, 102, 108, 115, 120
Working Through It
Sorted data: already done. Median (Q2) = 98
Lower half: 72, 85, 90, 95 → Q1 = (85 + 90) / 2 = 87.5
Upper half: 102, 108, 115, 120 → Q3 = (108 + 115) / 2 = 111.5
IQR = 111.5 - 87.5 = 24
The middle 50% of test scores span 24 points. This tells you students are fairly clustered in the 87.5 to 111.5 range. Anyone scoring outside this band is either struggling badly or acing it.
IQR vs Other Measures of Spread
You need to know when IQR is the right tool.
| Measure | What It Uses | Affected by Outliers? | Best For |
|---|---|---|---|
| IQR | Middle 50% (Q1 to Q3) | No | Skewed data, real-world datasets |
| Range | Min to Max | Yes, heavily | Quick estimate, no outliers |
| Variance | All data points | Yes | Statistical tests, probability |
| Standard Deviation | All data points | Yes | Normal distributions |
IQR wins when your data has outliers or doesn't follow a normal distribution. Range is useless if you have one extreme value. Variance and standard deviation get skewed by the same problems.
Using IQR to Find Outliers
This is where IQR becomes practical. You can identify outliers using the 1.5×IQR rule.
- Lower fence = Q1 - (1.5 × IQR)
- Upper fence = Q3 + (1.5 × IQR)
- Any data point outside these fences is a potential outlier
Going back to our test scores: Q1 = 87.5, Q3 = 111.5, IQR = 24
Lower fence: 87.5 - (1.5 × 24) = 87.5 - 36 = 51.5
Upper fence: 111.5 + (1.5 × 24) = 111.5 + 36 = 147.5
Our scores range from 72 to 120. All fall within the fences. No outliers here.
Common Mistakes That Give Wrong Answers
- Forgetting to sort first — This ruins everything. Always sort.
- Messing up median inclusion — With odd n, include median in both halves. With even n, exclude it.
- Confusing Q1 with the 25th percentile value — They're the same thing. Don't overthink it.
- Using IQR on normally distributed data — Standard deviation is better there.
When to Use IQR (and When Not To)
Use IQR when:
- Your data has outliers you suspect are errors
- You're analyzing salaries, home prices, or similar skewed distributions
- You need to create box plots
- You want to quickly identify extreme values
Skip IQR when:
- Your data is normally distributed and symmetric
- You need to perform parametric statistical tests (use standard deviation instead)
- Your sample size is tiny (less than 10 points)
Quick Reference
If you just need the formula for a formula sheet:
IQR = Q3 - Q1
Where:
- Q1 = median of lower half
- Q3 = median of upper half
- Both require sorted data first
That's the whole thing. Sort, find medians, subtract. The math is straightforward. The hard part is not making a stupid sorting error or including/excluding the median incorrectly when splitting your data.