statistics

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

The interquartile range (IQR) measures the spread of the middle 50% of values in a dataset and is a robust indicator of variability. To calculate IQR, first determine the first...

Mara Ellison
How to Calculate the Interquartile Range (IQR): A Step by Step Guide

The interquartile range (IQR) measures the spread of the middle 50% of values in a dataset and is a robust indicator of variability. To calculate IQR, first determine the first quartile (Q1, the 25th percentile) and the third quartile (Q3, the 75th percentile), then subtract Q1 from Q3 (IQR = Q3 − Q1). This summary explains how to calculate IQR by hand, using technology, and how to interpret the result for outlier detection and comparison with other dispersion metrics.

What the Interquartile Range Represents

The interquartile range captures the spread of the central portion of a distribution, minimizing the influence of extreme values. Unlike the full range (maximum minus minimum), the IQR focuses on the middle 50% of data, making it a reliable measure of variability for skewed distributions or data with outliers. A larger IQR indicates greater dispersion within the central data, while a smaller IQR signals that the middle values are closely packed.

Key Definitions and Concepts

  • Quartiles: Divides ordered data into four equal parts; Q1 is the 25th percentile, Q2 the median (50th percentile), and Q3 the 75th percentile.
  • IQR: The difference between Q3 and Q1, representing the range of the middle 50% of observations.
  • Outlier detection bounds: Typically, lower bound = Q1 − 1.5×IQR and upper bound = Q3 + 1.5×IQR; values outside these bounds are potential outliers.
  • Percentile: A value below which a given percentage of observations fall; methods for estimating percentiles vary, so results can depend on the chosen approach.

How to Calculate IQR by Hand

Calculating IQR manually involves ordering the data, locating quartiles, and subtracting Q1 from Q3.

Step 1: Order the Data

Arrange all observations from smallest to largest. Ordered data are required to consistently define positions for quartiles.

Step 2: Find the Median (Q2)

The median splits the dataset into lower and upper halves. If the number of observations (n) is odd, the median is the middle value; if n is even, it is the average of the two central values.

Step 3: Determine Q1 and Q3

With the median identified, treat the lower half (excluding the median for odd n) as the subset for Q1, and the upper half (excluding the median for odd n) for Q3. Find the medians of these halves to estimate Q1 and Q3.

Step 4: Compute IQR

Subtract Q1 from Q3 to obtain the IQR: IQR = Q3 − Q1. This value summarizes the spread of the central half of the data.

Worked Example: Small Dataset

Dataset: 4, 7, 8, 10, 12, 14, 19 (n = 7)

  • Ordered data: 4, 7, 8, 10, 12, 14, 19.
  • Median (Q2) = 10 (middle value).
  • Lower half (excluding median): 4, 7, 8 → Q1 = 7.
  • Upper half (excluding median): 12, 14, 19 → Q3 = 14.
  • IQR = 14 − 7 = 7.

Worked Example: Larger Dataset

Dataset: 3, 5, 5, 6, 7, 9, 11, 12, 14, 15 (n = 10)

  • Ordered data: 3, 5, 5, 6, 7, 9, 11, 12, 14, 15.
  • Median (Q2) = (7 + 9) / 2 = 8.
  • Lower half: 3, 5, 5, 6, 7 → Q1 = 5.
  • Upper half: 9, 11, 12, 14, 15 → Q3 = 12.
  • IQR = 12 − 5 = 7.

Using Technology to Calculate IQR

Software and calculators automate quartile computation and reduce manual errors, but method choices can affect results.

Tool / Method Verified Detail Source Type
Excel (QUARTILE.INC) Calculates quartiles including Q1 and Q3; IQR = QUARTILE.INC(data,3) − QUARTILE.INC(data,1) Software function
Excel (QUARTILE.EXC) Excludes endpoints; appropriate for certain methods but may return errors for small datasets Software function
Python (numpy) numpy.percentile(data, [25, 75]) returns Q1 and Q3; IQR = Q3 − Q1 Library function
R IQR() function computes IQR using a specified type to handle ties and interpolation Built-in function
Manual (odd n example) Dataset 4, 7, 8, 10, 12, 14, 19 → IQR = 7 Step-by-step calculation

Interpreting IQR and Identifying Outliers

Interquartile range is most commonly used to identify outliers and to describe variability without assuming symmetry.

Outlier Detection Fences

Using the IQR, compute lower and upper bounds to flag potential outliers:

  • Lower bound = Q1 − 1.5×IQR
  • Upper bound = Q3 + 1.5×IQR
  • Values below the lower bound or above the upper bound are considered potential outliers.

For the small dataset example above (IQR = 7), lower bound = 7 − 1.5×7 = −3.5 and upper bound = 14 + 1.5×7 = 24.5; no data points fall outside these bounds, so there are no outliers in this example.

Comparison with Other Spread Measures

  • Range: Difference between maximum and minimum; sensitive to outliers, whereas IQR is resistant.
  • Standard deviation: Reflects average deviation from the mean; assumes symmetry and can be influenced by extreme values, unlike IQR.
  • Variance: The square of the standard deviation; also sensitive to outliers, while IQR focuses on the central data.

Important Considerations and Limitations

Because quartile definitions vary, IQR results can depend on the method used to compute percentiles. Different statistical software packages may return slightly different quartiles for the same data, especially with small or tied values. The 1.5×IQR rule for outliers is a common guideline but not a universal threshold; context and domain knowledge should guide outlier decisions. IQR describes the middle 50% of data and does not capture the behavior of tails; it should be used alongside other summaries for a complete picture of variability.

When and Why to Use IQR

Use the IQR when you need a robust measure of spread that is not affected by extreme values. It is especially useful for skewed distributions, data with outliers, and when comparing variability across groups. In exploratory data analysis, IQR helps identify inconsistencies, potential data entry errors, and natural extremes. Paired with visual tools like box plots, it provides an intuitive summary of dispersion and central tendency.

The interquartile range is a foundational, reliable tool for summarizing spread and detecting outliers. By focusing on the middle half of the data, it offers clarity and stability in diverse analytical contexts.

Tags: statistics, IQR, quartiles, outlier detection, descriptive statistics

Related Reading

More pages in this topic cluster.

Bell Shaped Distribution Graph: Definition, Properties, and Examples

A bell shaped distribution graph shows how data points cluster around a central value with frequencies that taper off symmetrically toward the extremes. The classic bell curve a...

Read next
Systematic Definition of Statistics: Principles, Methods, and Uses

Statistics is the systematic science of collecting, describing, analyzing, and interpreting quantitative information to support reasoned decision-making under uncertainty. A sys...

Read next
How to Plot Standard Deviation: A Practical Guide

Standard deviation quantifies how far data points tend to lie from their mean, and plotting it correctly helps you communicate variability and uncertainty clearly. This guide wa...

Read next