Interquartile Range Calculator (IQR) – Step-by-Step with Box Plot & Outliers

Interquartile Range & Box Plot Calculator ΔQ = Q₃ − Q₁

Find the quartiles Q₁, Q₂ (median), Q₃ and the interquartile range ΔQ for raw data or for grouped data. For raw data the calculator also flags outliers with the 1.5·ΔQ rule and draws a box-and-whisker plot; every result comes with a step-by-step solution.

🎯 Quartile Knowledge Quiz

Question 1: Given the sorted data 2, 4, 6, 8, 10, 12, 14, the interquartile range ΔQ is:

Question 2: In statistics, what does the interquartile range ΔQ measure?

Question 3: A grouped data set has Q₁ = 45 and Q₃ = 70. The interquartile range ΔQ is:

Quartiles, the interquartile range (IQR) and box plots are core tools of descriptive statistics. They describe where the middle of the data lies and how spread out it is, and they make unusual values easy to spot. The calculator above handles both situations you meet in class in two tabs. The Raw Data tab takes any list of numbers, sorts it, finds Q₁, Q₂, Q₃ and the IQR, flags outliers with the 1.5 × IQR rule and draws a box-and-whisker plot. The Grouped Data tab takes a frequency table with as many classes as you need, builds the cumulative frequency table and finds each quartile by interpolation, giving exact fractions as well as decimals. Every result comes with a step-by-step solution you can compare with your work, copy, or print on A4 paper.

Box plot of the incomes of 11 employees: box from Q₁ = 8 to Q₃ = 18, median line at 11, left whisker to 5, dashed upper fence at 33, two outliers at 45 and 50.0510152025303540455055Q₁ = 8Q₂ = 11Q₃ = 18Q₃ + 1.5·IQR = 3354550Outliers
Box plot of Example 3. The blue box runs from Q₁ = 8 to Q₃ = 18 (IQR = 10) and the amber line is the median Q₂ = 11. The whiskers reach the minimum 5 and the largest non-outlier 18; the red dots 45 and 50 lie beyond the fence Q₃ + 1.5·IQR = 33, so they are outliers.

📚 What are quartiles?

Quartiles are the three values Q₁, Q₂, Q₃ that split a data set sorted in non-decreasing order into four parts, each holding about 25% of the data:

  • Q₁ – first (lower) quartile: about 25% of the data are less than or equal to Q₁.
  • Q₂ – second quartile: this is the median, which splits the data in half.
  • Q₃ – third (upper) quartile: about 75% of the data are less than or equal to Q₃.

In other words, Q₂ cuts the data into two halves, Q₁ is the “median of the lower half” and Q₃ is the “median of the upper half”. Together with the minimum and maximum they form the five-number summary (min, Q₁, Q₂, Q₃, max), which is all you need to draw a box plot.

📐 The interquartile range

The interquartile range is the difference between the third and first quartiles:

IQR = ΔQ = Q₃ − Q₁

The IQR is the length of the interval [Q₁; Q₃], which contains the middle 50% of the data. A large IQR means the middle half is widely spread; a small IQR means the data cluster tightly around the median. Because it ignores the lowest 25% and the highest 25% of values, the IQR is hardly affected by extreme values — its main advantage over the range.

CriterionRange RInterquartile range
FormulaR = max − minIQR = Q₃ − Q₁
Depends onThe two most extreme valuesThe middle 50% of the data
Effect of outliersVery strong ❌Very small ✅
Best used forEven data, quick estimatesData that may contain outliers; stable comparisons of spread

🔢 Quartiles of raw (ungrouped) data

  1. Sort the data in non-decreasing order: x₁ ≤ x₂ ≤ … ≤ xₙ.
  2. Find the median Q₂. If n is odd, Q₂ = x₍ₙ₊₁₎/₂; if n is even, Q₂ = (xₙ/₂ + xₙ/₂₊₁)/2.
  3. Find Q₁ and Q₃. Q₁ is the median of the values to the left of Q₂ and Q₃ is the median of the values to the right. When n is odd, leave the median out of both halves; when n is even, each half has exactly n/2 values.
  4. Compute the IQR Q₃ − Q₁.

This “median of halves” method (sometimes called the exclusive or Tukey method) is the one used in most school textbooks and on most handheld calculators. The calculator shows the sorted data as coloured chips — blue for the lower half, green for the upper half, amber for the median when n is odd — with a bold ring around the values used for Q₁, Q₂ and Q₃, so you can see exactly where each quartile comes from.

💡 Worked examples

Example 1. Even sample size: test scores of 10 students

Scores out of 30: 3, 5, 7, 8, 12, 13, 14, 18, 21, 25. Find the quartiles and the IQR.

  • The data are sorted and n = 10 is even. The two middle values are x₅ = 12 and x₆ = 13, so Q₂ = 12.5.
  • Lower half 3, 5, 7, 8, 12 has median Q₁ = 7; upper half 13, 14, 18, 21, 25 has median Q₃ = 18.
  • IQR = 18 − 7 = 11. Five-number summary: 3, 7, 12.5, 18, 25.

The fences are 7 − 1.5·11 = −9.5 and 18 + 1.5·11 = 34.5; every value lies between them, so there are no outliers. This is the “Ex1” button in the calculator.

Example 2. Odd sample size: 100 m sprint times

Times (seconds) of 11 sprinters: 12.5, 13.2, 13.8, 14.1, 14.5, 14.8, 15.2, 15.6, 16.1, 16.8, 17.5.

  • n = 11 is odd, so the median is value number (11 + 1)/2 = 6: Q₂ = 14.8.
  • Leaving 14.8 out, the lower half 12.5, 13.2, 13.8, 14.1, 14.5 gives Q₁ = 13.8 and the upper half 15.2, 15.6, 16.1, 16.8, 17.5 gives Q₃ = 16.1.
  • IQR = 16.1 − 13.8 = 2.3 seconds: the middle half of the sprinters are within 2.3 seconds of each other.

A common mistake is to include 14.8 in both halves, which gives Q₁ = 13.95 and Q₃ = 15.85 — not the textbook answer.

Example 3. Detecting outliers

Monthly income (millions) of 11 employees: 5, 7, 8, 9, 10, 11, 12, 15, 18, 45, 50.

  • n = 11: Q₂ = x₆ = 11; the lower half 5, 7, 8, 9, 10 gives Q₁ = 8; the upper half 12, 15, 18, 45, 50 gives Q₃ = 18; IQR = 10.
  • Lower fence Q₁ − 1.5·IQR = −7, upper fence Q₃ + 1.5·IQR = 33.
  • 45 and 50 are above 33, so they are outliers.

The range R = 50 − 5 = 45 is stretched by these two values, while IQR = 10 still describes the spread of most employees. The box plot at the top of this page is the plot of this example (the “Ex3” button).

⚠️ The 1.5 × IQR rule for outliers

A value x is an outlier if

[a₁; a₂), [a₂; a₃), …, the individual values are unknown, so we cannot split the list in half. Instead, we find the class that contains each quartile and interpolate linearly inside it.

  1. Find the sample size n = m₁ + m₂ + … + mₖ and build the cumulative frequency table.
  2. The positions of Q₁, Q₂, Q₃ are n/4, n/2, 3n/4.
  3. The quartile class is the first class whose cumulative frequency is at least that position. Call it [aₚ; aₚ₊₁) with frequency mₚ, and let C be the cumulative frequency of the class just before it.
  4. Apply the interpolation formula.
Q₁ = aₚ + (n/4 − C)/mₚ · (aₚ₊₁ − aₚ)
Q₂ = aₚ + (n/2 − C)/mₚ · (aₚ₊₁ − aₚ); Q₃ = aₚ + (3n/4 − C)/mₚ · (aₚ₊₁ − aₚ)

Each quartile has its own class, so p, C and mₚ change from one formula to the next. The IQR of grouped data is still Q₃ − Q₁, and it is an estimate of the IQR of the original raw data.

Example 4. Exam scores of 50 candidates

Score class[0; 3)[3; 5)[5; 7)[7; 9)[9; 10]
Candidates mᵢ51218105
Cumulative frequency517354550
  • n = 50. The position of Q₁ is 50/4 = 12.5; the first class with cumulative frequency ≥ 12.5 is [3; 5) with C = 5 and mₚ = 12: Q₁ = 3 + (12.5 − 5)/12 · 2 = 4.25.
  • The position of Q₂ is 25, in [5; 7) with C = 17 and mₚ = 18: Q₂ = 5 + 8/18 · 2 = 53/9 ≈ 5.89.
  • The position of Q₃ is 37.5, in [7; 9) with C = 35 and mₚ = 10: Q₃ = 7 + 2.5/10 · 2 = 7.5.
  • IQR = 7.5 − 4.25 = 3.25 points.

This table is the “Ex1” button in the Grouped Data tab; the calculator highlights the classes containing Q₁, Q₂ and Q₃ in the cumulative frequency table so you can follow each step.

🎓 Checking with a calculator

Casio fx-991EX / fx-570EX (ClassWiz): press MENU, choose Statistics → 1-Variable, enter the data in the x column, press AC and then OPTN → 1-Variable Calc. The screen lists minX, Q₁, Med, Q₃ and maxX; subtract Q₁ from Q₃ for the IQR and compare with the calculator’s solution.

Important: for grouped data, entering class midpoints with frequencies makes the calculator report the quartiles of the midpoint list, not the interpolated grouped quartiles. Spreadsheet functions such as Excel’s QUARTILE.INC also use a different interpolation convention, so their Q₁ and Q₃ can differ from the median-of-halves method. Follow the method your course uses — the one shown in the calculator’s solution.

⚠️ Common mistakes

  1. Forgetting to sort the data before finding the median and quartiles.
  2. Including the median in both halves when n is odd, which shifts Q₁ and Q₃.
  3. Confusing position with value: (n + 1)/2 tells you which value is the median, not the median itself.
  4. Mixing up the IQR and the range (Q₃ − Q₁ is not max − min).
  5. Using one class for all three grouped quartiles, or taking C as the cumulative frequency of the quartile class itself instead of the class before it.
  6. Deleting outliers automatically without checking why they occur.

❓ Frequently asked questions (FAQ)

Why is the IQR better than the range when there are outliers?

The range R = max − min depends only on the two most extreme values, so a single outlier can change it dramatically. The IQR = Q₃ − Q₁ depends only on the middle 50% of the data. For 5, 6, 6, 7, 7, 8, 8, 9, 9, 100 the range is 95, but Q₁ = 6 and Q₃ = 9, so the IQR is 3 and correctly reflects the spread of most of the data.

When n is odd, is the median included in the halves used for Q₁ and Q₃?

No. With the median-of-halves method, when n is odd the median is left out and each half has (n − 1)/2 values; Q₁ is the median of the lower half and Q₃ the median of the upper half. When n is even, each half has exactly n/2 values.

When should outliers be removed from data?

Only when you are sure they come from a typing or measurement error, or do not belong to the population being studied. If an outlier is a genuine case (a very high income, a record rainfall), keep it and describe the data with the median and IQR rather than the mean.

How is the median Q₂ different from the mean?

The median is the middle value after sorting, while the mean is the sum of the values divided by the sample size. For 1, 2, 3, 4, 100 the median is 3 but the mean is 22. The median is barely affected by outliers, whereas the mean is pulled strongly towards them.

How are quartiles of grouped data calculated?

Build the cumulative frequency table, find the first class whose cumulative frequency is at least n/4 (for Q₁), n/2 (for Q₂) or 3n/4 (for Q₃), then interpolate: Q = aₚ + (position − C)/mₚ · (aₚ₊₁ − aₚ), where C is the cumulative frequency of the previous class and mₚ is the frequency of the quartile class.

What does a box plot tell you about the data?

A box plot shows the five-number summary (min, Q₁, Q₂, Q₃, max), the spread of the middle half through the length of the box, the skewness through the position of the median line and the whisker lengths, and any outliers as separate dots. Several box plots on one axis make it easy to compare groups.

🔗 Related tools