Calculating the IQR

Introduction

Welcome back to Measuring Spread and Variability! This is lesson three of four, which means we are almost done with this course. So far, we have measured spread using the range and learned how to locate Q1, Q2 (the median), and Q3 to divide a dataset into four roughly equal groups. Now it is time to put those quartile skills to work. In this lesson, we will calculate and interpret the interquartile range (IQR) — a measure of spread that zeroes in on the middle 50% of the data and ignores the extremes.

Why the Middle 50% Matters

Imagine two classrooms that both scored a median of 78 on an exam. In Classroom A, the middle half of scores runs from 72 to 84. In Classroom B, the middle half stretches from 60 to 96. Even though both classes share the same center, the experience of teaching them would feel very different because Classroom B has far more variability among its students.

The interquartile range gives us a single number to capture exactly this kind of difference. By measuring only the span of the middle 50%, we get a sense of how tightly or loosely the "typical" values are clustered — without being thrown off by a few unusually high or low scores.

Two dot plots comparing Classroom A and Classroom B exam score spreads with the same median but different IQRs

The IQR Formula

A Worked Example

Interpreting the IQR in Context

A number by itself only tells part of the story. The IQR becomes truly useful when we tie it back to the situation at hand. Consider our step-count example: an IQR of 1,900 out of a median around 7,600 suggests moderate day-to-day consistency. If the IQR had been only 400, we would say our daily activity was very steady. If it had been 4,000, we would say our routine varied quite a bit from one day to the next.

IQR Relative to the DataWhat It Suggests
Small compared to the medianThe middle 50% is tightly packed; typical values are fairly consistent.
Large compared to the medianThe middle 50% is spread wide; there is more variability among typical values.

When writing or speaking about the IQR, always connect the number to the real-world context. Saying "the IQR is 1,900" is correct but incomplete. Saying "the middle half of daily step counts spans about 1,900 steps" paints a picture that is much easier to understand.

Why the IQR Resists Outliers

Conclusion and Next Steps

Sign up

Join the 1M+ learners on CodeSignal

Be a part of our community of 1M+ users who develop and demonstrate their skills on CodeSignal