Math glossary

Interquartile Range: Formula, Box Plots, and Outliers

Calculate interquartile range from quartiles, read a box plot, and apply the 1.5 IQR rule. Compare methods with six examples.

TL;DR

The interquartile range is Q3−Q1Q_3-Q_1, the distance between the upper and lower quartiles. It measures the spread of the middle of a dataset and helps flag unusually low or high values.

Key Points

  • The lower quartile is Q1Q_1, the median is Q2Q_2, and the upper quartile is Q3Q_3.
  • The interquartile range has the same units as the data.
  • The usual outlier fences are Q1−1.5IQRQ_1-1.5\,\mathrm{IQR} and Q3+1.5IQRQ_3+1.5\,\mathrm{IQR}.
  • Quartile conventions can change the reported result on small datasets.
  • A flagged outlier needs investigation before any decision to remove it.

What is the interquartile range?

The interquartile range, or IQR, measures the width of the middle portion of ordered data. It runs from the first quartile Q1Q_1, near the 25th percentile, to the third quartile Q3Q_3, near the 75th percentile. The second quartile Q2Q_2 is the median.

IQR=Q3−Q1.\mathrm{IQR}=Q_3-Q_1.

The IQR spans the middle 50% in the percentile sense. In a small dataset or one with many ties, the number of observations on or inside the quartile boundaries can differ from exactly half. OpenStax and CUNY explain quartiles as locations in ordered data.

The median, range, and outliers lesson compares an extreme-to-extreme range with a measure of the center. The IQR adds a third option. It describes the spread around that center and usually changes less than the full range when one extreme observation changes.

How do you calculate the IQR by hand?

Use the median-of-halves method if your course specifies it. The version used for the examples here excludes the overall median from the two halves when the dataset has an odd number of observations.

  1. Sort the values from smallest to largest.
  2. Find the overall median. If the dataset size is even, split it evenly. If it is odd, set aside the single median value.
  3. Find the median of the lower half for Q1Q_1 and the median of the upper half for Q3Q_3.
  4. Subtract Q1Q_1 from Q3Q_3.

Keep the units. If the quartiles are 8 minutes and 15 minutes, the IQR is 7 minutes. A negative IQR means the subtraction order or placement of the quartiles needs checking.

Why can a spreadsheet return a different IQR?

Software may compute the 25th and 75th percentiles using interpolation. Courses can also differ on whether the overall median joins both halves for an odd-length list. NIST’s quantile reference documents multiple percentile methods.

For 2,4,7,9,142,4,7,9,14, excluding the middle 7 gives lower and upper quartiles of 3 and 11.5, so the IQR is 8.5. Including the 7 in both halves gives quartiles of 4 and 9, so the IQR is 5. Before comparing answers, check whether both calculations used the same rule.

How does the IQR appear on a box plot?

In a box plot, the two ends of the box mark Q1Q_1 and Q3Q_3. The line inside marks the median. Read the box width along the number scale to get IQR. A wide box shows a larger middle spread when you compare plots drawn on the same scale.

Box plot with quartiles at three and nine, median at six, upper whisker at ten, and an outlier at twenty
The box spans 3 to 9, so the IQR is 6. The upper fence is 18, and the value 20 is drawn as a separate point.

Many box plots use whiskers that extend to the most extreme observations still inside the fences. Some simpler box plots instead extend to the minimum and maximum. OpenStax’s box-plot lesson shows the five-number summary, and the NIST handbook describes the fence-based version. Read the chart’s convention before inferring which observations its whiskers cover.

How do you find outliers with the 1.5 IQR rule?

Find the quartiles using the intended convention. Then compute two boundaries.

Lower fence&=Q1−1.5IQR,Upper fence&=Q3+1.5IQR.\begin{aligned} \text{Lower fence}&=Q_1-1.5\,\mathrm{IQR},\\ \text{Upper fence}&=Q_3+1.5\,\mathrm{IQR}. \end{aligned}

A value strictly below the lower fence or strictly above the upper fence is flagged. A value exactly on a fence is inside by this convention. The fences are calculated positions and do not need to be observed values. The NIST outliers guide distinguishes these positions from the end of a whisker.

A flag can point to a data-entry error, a different subgroup, or an unusual but valid observation. Inspect the measurement and surrounding context before making a decision. If the IQR is zero because many values tie, even a small departure can be flagged.

Examples of Interquartile Range

Example 1

Find the IQR of 2,3,5,6,7,8,10,122,3,5,6,7,8,10,12.

  1. The lower half is 2,3,5,62,3,5,6, so Q1=(3+5)/2=4Q_1=(3+5)/2=4.
  2. The upper half is 7,8,10,127,8,10,12, so Q3=(8+10)/2=9Q_3=(8+10)/2=9.
  3. The IQR is 9−4=59-4=5.

Example 2

Find the quartiles of 2,4,7,9,142,4,7,9,14 using the method that excludes the overall median.

  1. Set aside the middle value 7.
  2. The lower half 2,42,4 gives Q1=3Q_1=3. The upper half 9,149,14 gives Q3=11.5Q_3=11.5.
  3. The IQR is 11.5−3=8.511.5-3=8.5. Leaving 7 in the halves would apply a different method.

Example 3

Check 1,2,4,5,7,8,10,201,2,4,5,7,8,10,20 for outliers.

  1. The quartiles are Q1=3Q_1=3 and Q3=9Q_3=9. The IQR is 6.
  2. Multiply by 1.5 to get 9. The fences are 3−9=−63-9=-6 and 9+9=189+9=18.
  3. The value 20 is above the upper fence. The greatest observed value within the upper fence is 10, so the upper whisker ends at 10.

Example 4

Compare the IQR and full range before and after replacing 12 with 40 in 0,3,5,6,7,8,10,120,3,5,6,7,8,10,12.

  1. The original full range is 12−0=1212-0=12. After replacement it is 40−0=4040-0=40.
  2. In both datasets the middle of the lower half is 4, and the middle of the upper half is 9.
  3. Both IQRs equal 5. Changing that largest value affects the full range without affecting the middle-half spread in this example.

Example 5

Find the semi-interquartile range for quartiles 3 and 11.5.

  1. Subtract to get the IQR of 8.5.
  2. The semi-interquartile range, sometimes called quartile deviation, equals half the IQR.
  3. Its value is 8.5/2=4.258.5/2=4.25.

Example 6

Find the quartile-based outlier flags for 4,4,4,4,4,4,4,94,4,4,4,4,4,4,9.

  1. Both half-medians equal 4, giving IQR 4−4=04-4=0.
  2. Both fences equal 4.
  3. The value 9 is flagged. The repeated 4s explain the tight fences, so investigate the 9 using the measurement context.

What mistakes should you check before comparing IQRs?

Mistake 1: Taking the difference between the endpoints of the dataset

For Example 3, 20−1=1920-1=19 is the full range. The IQR uses the box endpoints 3 and 9, yielding 6. Identify which two values the question asks you to subtract.

Mistake 2: Using the median as the center of both fences

The lower fence starts at Q1Q_1 and the upper fence starts at Q3Q_3. Using the median as the starting point shifts both boundaries inward and can flag ordinary data.

Mistake 3: Comparing values from different quartile conventions

On a short list, switching conventions can change Q1Q_1, Q3Q_3, and the flags. Record the quartile method beside the result, particularly if comparing a hand calculation with a spreadsheet.

Try It Yourself

  1. Find the IQR when Q1=12Q_1=12 and Q3=18Q_3=18.
  2. For those quartiles, calculate both fences and decide if 27 is beyond the upper fence.
  3. Find the median and IQR of 2,4,6,82,4,6,8 using the median-of-halves method.

Answers and Reasoning

  1. The IQR is 18−12=618-12=6.
  2. The fences are 12−9=312-9=3 and 18+9=2718+9=27. The value 27 is on the upper fence, so it is not beyond it.
  3. The median is (4+6)/2=5(4+6)/2=5. The two half-medians are 3 and 7, so the IQR is 4.

Questions About Interquartile Range

Is the IQR the same as the median?

The median describes a central value. The IQR describes a width. Two groups can have the same median and different IQRs.

When is the IQR useful alongside standard deviation?

The IQR pairs naturally with the median to describe skewed data or data with unusual values. Standard deviation measures variation around the mean. Reporting both can reveal different aspects of spread. The variance lesson shows where the squared deviations enter that calculation.

Can the interquartile range be zero?

Yes, when Q1=Q3Q_1=Q_3. This can happen in a dataset with many repeated values even though some values differ from them.

Conclusion

  • Sort the data and calculate quartiles using the intended method.
  • Subtract the lower quartile from the upper quartile to measure the middle spread.
  • Use the 1.5IQR1.5\,\mathrm{IQR} fences to flag values for a closer look.

Read More

Research Behind This Article

  1. OpenStax, Introductory Statistics 2e: Measures of the Location of the Data. OpenStax
  2. City University of New York, Concepts in Statistics: Interquartile Range and Boxplots. CUNY Pressbooks
  3. National Institute of Standards and Technology, Dataplot Reference: Quantile. NIST
  4. OpenStax, Statistics: Box Plots. OpenStax
  5. NIST/SEMATECH, Engineering Statistics Handbook: What Are Outliers in the Data? NIST