Skip to main content
Вернуться к руководствам
6 min read6 Шаги

How to Calculate the Interquartile Range (IQR): Step-by-Step Guide

Learn to calculate the Interquartile Range (IQR) and five-number summary by hand. Understand Q1, Q2, Q3, and identify outliers with a detailed example.

Оставьте математику — воспользуйтесь калькулятором

Пошаговые инструкции

1

Gather and Order Your Data

Begin by listing all your data points and arranging them in ascending order (from smallest to largest). This is a critical first step for all subsequent calculations.

2

Calculate the Median (Q2)

Find the median (Q2) of the entire ordered dataset. If the number of data points (N) is odd, the median is the middle value. If N is even, the median is the average of the two middle values.

3

Determine Q1 (Lower Quartile)

Identify the lower half of your data. If N was odd, exclude the overall median (Q2) from this half. Calculate the median of this lower half; this value is Q1.

4

Determine Q3 (Upper Quartile)

Identify the upper half of your data. If N was odd, exclude the overall median (Q2) from this half. Calculate the median of this upper half; this value is Q3.

5

Calculate the Interquartile Range (IQR)

Apply the formula: IQR = Q3 - Q1. This value represents the spread of the middle 50% of your data.

6

Identify Potential Outliers

Use the 1.5×IQR rule: Calculate the Lower Bound (Q1 - 1.5×IQR) and the Upper Bound (Q3 + 1.5×IQR). Any data point falling outside these bounds is considered an outlier.

The Interquartile Range (IQR) is a crucial measure of statistical dispersion, representing the middle 50% of a dataset. Unlike the standard range (maximum - minimum), the IQR is robust to outliers, making it a more reliable indicator of data spread in many scenarios. Understanding how to calculate the IQR, along with the five-number summary, is fundamental for data analysis, especially when identifying potential outliers.

This guide will walk you through the manual calculation of the IQR, the five-number summary (minimum, Q1, median, Q3, maximum), and the identification of outliers using the 1.5×IQR rule. We will provide a clear formula, a detailed worked example, and highlight common pitfalls to ensure accuracy.

Prerequisites

Before diving into the calculation, ensure you have a basic understanding of:

  • Ordering Data: Arranging numbers from smallest to largest.
  • Median: The middle value of an ordered dataset.

Understanding Quartiles and the Five-Number Summary

The IQR is based on quartiles, which divide an ordered dataset into four equal parts:

  • Q1 (First Quartile / Lower Quartile): This is the median of the lower half of the data. 25% of the data falls below Q1.
  • Q2 (Second Quartile / Median): This is the overall median of the dataset. 50% of the data falls below Q2.
  • Q3 (Third Quartile / Upper Quartile): This is the median of the upper half of the data. 75% of the data falls below Q3.

The Five-Number Summary provides a concise overview of your dataset's distribution and consists of:

  1. Minimum: The smallest value in the dataset.
  2. Q1: The first quartile.
  3. Median (Q2): The second quartile.
  4. Q3: The third quartile.
  5. Maximum: The largest value in the dataset.

The Interquartile Range (IQR) Formula

The IQR is simply the difference between the third quartile (Q3) and the first quartile (Q1):

IQR = Q3 - Q1

Identifying Outliers using the 1.5×IQR Rule

Outliers are data points that significantly deviate from other observations. The 1.5×IQR rule is a common method for their detection:

  • Lower Bound for Outliers: Q1 - (1.5 × IQR)
  • Upper Bound for Outliers: Q3 + (1.5 × IQR)

Any data point that falls below the Lower Bound or above the Upper Bound is considered a potential outlier.

Worked Example: Calculating IQR and Outliers

Let's calculate the IQR and identify outliers for the following dataset:

[3, 7, 8, 5, 12, 14, 21, 13, 18]

Step 1: Gather and Order Your Data

First, arrange the data points in ascending order:

[3, 5, 7, 8, 12, 13, 14, 18, 21]

Here, the total number of data points (N) is 9.

Step 2: Calculate the Median (Q2)

The median (Q2) is the middle value of the entire ordered dataset.

  • Since N=9 (an odd number), the median is the (N+1)/2-th value.
  • (9+1)/2 = 5-th value.
  • Counting from the beginning, the 5th value is 12.

So, Median (Q2) = 12.

Step 3: Determine Q1 (Lower Quartile)

Q1 is the median of the lower half of the data. For an odd N, we exclude the overall median (Q2) when splitting the data.

  • Lower half of the data (excluding 12): [3, 5, 7, 8]
  • Here, N=4 (an even number). The median is the average of the two middle values: the (N/2)-th and (N/2 + 1)-th values.
  • The 2nd and 3rd values are 5 and 7.
  • Q1 = (5 + 7) / 2 = 12 / 2 = 6.

So, Q1 = 6.

Step 4: Determine Q3 (Upper Quartile)

Q3 is the median of the upper half of the data. Again, for an odd N, we exclude the overall median (Q2).

  • Upper half of the data (excluding 12): [13, 14, 18, 21]
  • Here, N=4 (an even number). The median is the average of the two middle values: the (N/2)-th and (N/2 + 1)-th values.
  • The 2nd and 3rd values are 14 and 18.
  • Q3 = (14 + 18) / 2 = 32 / 2 = 16.

So, Q3 = 16.

Step 5: Calculate the Interquartile Range (IQR)

Now, apply the IQR formula:

  • IQR = Q3 - Q1
  • IQR = 16 - 6 = 10

So, IQR = 10.

Step 6: Identify Potential Outliers

Using the 1.5×IQR rule:

  1. Calculate 1.5 × IQR: 1.5 × 10 = 15

  2. Calculate the Lower Bound: Q1 - (1.5 × IQR) = 6 - 15 = -9

  3. Calculate the Upper Bound: Q3 + (1.5 × IQR) = 16 + 15 = 31

Now, examine your original sorted data [3, 5, 7, 8, 12, 13, 14, 18, 21] to see if any values fall outside the range [-9, 31].

In this example, all data points are within this range. Therefore, there are no outliers in this dataset.

The Five-Number Summary for Our Example

Based on our calculations:

  • Minimum: 3
  • Q1: 6
  • Median (Q2): 12
  • Q3: 16
  • Maximum: 21

Common Pitfalls to Avoid

  • Not Sorting Data: Always sort your dataset from smallest to largest before performing any calculations. This is the most common error.
  • Incorrectly Identifying the Median (Q2): Remember to average the two middle numbers for an even number of data points (N) or take the single middle number for an odd N.
  • Incorrectly Splitting Data for Q1 and Q3: When N is odd, it's common practice (and the method used in this guide, often called Tukey's Hinges) to exclude the overall median (Q2) when forming the lower and upper halves for Q1 and Q3 calculations. If N is even, the dataset naturally splits into two equal halves without excluding any values.
  • Calculation Errors: Double-check your arithmetic, especially with the 1.5 multiplier and additions/subtractions for outlier bounds.

When to Use an IQR Calculator

While understanding the manual process is vital, for larger datasets or when conducting frequent analyses, an online IQR calculator offers significant advantages:

  • Speed and Efficiency: Quickly get results without manual sorting and calculation.
  • Accuracy: Reduces the risk of human error, especially with long lists of numbers.
  • Convenience: Instantly provides the five-number summary and outlier identification, saving time for interpretation rather than computation.

By mastering the manual calculation, you gain a deeper understanding of your data's distribution. For practical application with extensive datasets, leveraging a reliable calculator streamlines your analytical workflow.

Готовы рассчитать?

Откажитесь от ручной работы и получите мгновенные результаты.

Открыть калькулятор

Сопутствующий смарт-контент

Настройки