Site icon Business with blogging!

How to Calculate IQR (Interquartile Range): A Simple Guide with Examples

How to Calculate IQR (Interquartile Range): A Simple Guide with Examples

The interquartile range, or IQR, is a simple but powerful tool in statistics. It shows how spread out the middle 50% of values in a dataset are. IQR is used in schools, data analysis, science, and even in real-life decisions like spotting unusual results or filtering outliers in messy data.

In this guide, you’ll learn what IQR means, how to calculate it step-by-step, and where it’s most useful.

What Is IQR and Why Does It Matter?

IQR stands for Interquartile Range. It measures the spread of the middle half of a dataset—from the first quartile (Q1) to the third quartile (Q3).

IQR is often used in box plots and is helpful for spotting outliers or understanding how tightly the central values in your data are grouped.

Step-by-Step: How to Calculate IQR Manually

You don’t need advanced math to find the IQR. Just follow these steps:

  1. Sort the numbers from smallest to largest.
  2. Find the median (middle number). This is the second quartile, or Q2.
  3. Find Q1, which is the median of the lower half of the data (before Q2).
  4. Find Q3, the median of the upper half of the data (after Q2).
  5. Subtract Q1 from Q3. That’s your IQR.

This gives you a number that shows how wide the “middle chunk” of your data is. If your dataset has an odd number of values, leave the median out when splitting the halves.

IQR Example with Numbers

Here’s a sample dataset:
2, 4, 5, 7, 8, 10, 12

  1. Q2 (median) = 7
  2. Lower half: 2, 4, 5 → Q1 = 4
  3. Upper half: 8, 10, 12 → Q3 = 10
  4. IQR = Q3 − Q1 = 10 − 4 = 6

The IQR is 6. This means the middle 50% of the data points fall within a spread of 6 units.

What Does IQR Tell Us About Data?

IQR gives you an idea of how concentrated or spread out the center of your dataset is. Unlike the full range, it’s not affected by extreme values or outliers.

If your IQR is small, most of your data is close together. If it’s large, your data is more spread out in the middle.

IQR is also used in outlier detection. If a value is:

…it’s often considered an outlier.

IQR vs. Range and Standard Deviation

How is IQR different from other measures of spread?

Measure What it Shows Sensitive to Outliers?
Range Difference between highest and lowest values Yes
Standard Deviation Spread around the mean Yes
IQR Spread of the middle 50% of data No

IQR is more robust when the data has outliers or is skewed. It doesn’t care about extreme highs or lows.

Using IQR in Box Plots and Outlier Detection

You’ll often see IQR used in box-and-whisker plots (or box plots). These show the minimum, Q1, median, Q3, and maximum values in a clean visual.

The box in a box plot spans from Q1 to Q3. The “whiskers” extend to data points that fall within 1.5 × IQR from Q1 and Q3. Anything beyond those whiskers is marked as an outlier.

Box plots help you see how the data is spread out and whether it’s skewed or balanced.

How to Calculate IQR Using Tools (Excel or Python)

In Excel:

 

In Python (with NumPy):

import numpy as np
data = [2, 4, 5, 7, 8, 10, 12]
q1 = np.percentile(data, 25)
q3 = np.percentile(data, 75)
iqr = q3 – q1
print(iqr) # Output: 6.0

These tools save time, especially with large datasets.

Conclusion

The interquartile range is a clean, reliable way to measure the spread of the middle part of your data. It’s easy to calculate, even by hand, and it helps you spot unusual values quickly.

Before diving into complex statistics, learn IQR well—it’s one of the simplest tools that gives strong insights into how your data behaves.

Practice on your own dataset and try plotting it. You’ll understand your numbers better and make smarter decisions based on them.

Exit mobile version