Course contentsShow
← Data Science
Lesson 1383 of 2,14535. Statistical Anomaly DetectionFree lesson

Understanding the Interquartile Range (IQR)

Learn how IQR measures spread by capturing the middle 50% of data between Q1 and Q3.

Understanding the Interquartile Range (IQR)

You'll learn how IQR captures the spread of the middle 50% of your data, making it a robust measure for detecting outliers.

What Is the IQR?

The Interquartile Range (IQR) measures the spread of data by focusing exclusively on the middle half of your dataset. Unlike range (which uses min and max), IQR captures where the "typical" values cluster by measuring the distance between the first quartile (Q1) and the third quartile (Q3).

Think of it like this: imagine lining up everyone in a city by height. Q1 is the height of the person at the 25% mark, and Q3 is at the 75% mark. The IQR is simply the difference between these two heights—it tells you the height range of the middle 50% of people, ignoring the extremely short or tall outliers.

Why IQR Matters for Anomaly Detection

The IQR is resistant to outliers, unlike standard deviation. Extreme values don't distort it because it only looks at the middle bulk of your data. This makes it especially valuable when you suspect your data contains anomalies that would skew other spread measures.

Formula:

IQR = Q3 - Q1

Where:

  • Q1 (25th percentile): 25% of data falls below this value
  • Q3 (75th percentile): 75% of data falls below this value

Using IQR to Find Outliers

The standard rule: any value below Q1 - 1.5 × IQR or above Q3 + 1.5 × IQR is considered a potential outlier. These boundaries create "fences" that separate typical values from suspicious ones.

Key Takeaway: The IQR measures spread by capturing the range of the middle 50% of data between Q1 and Q3, providing a robust, outlier-resistant method for understanding data distribution and detecting anomalies.