This IQR calculator finds the interquartile range of a set of up to 50 values, helping you understand the spread and distribution of your dataset. The article below explains the interquartile range definition, how to find the interquartile range using the IQR formula, and shows a fully worked example of calculating the interquartile range.

What is interquartile range? - What is IQR?

You may have heard the term interquartile range and asked yourself, "What is interquartile range anyway?". The interquartile range (IQR) of a dataset tells us how bunched up or spread out its values are (its a measure of variability). Other names you may come across for IQR include midspread, middle 50%, and H-spread.

IQR is the difference between the 75th percentile (upper quartile - Q3) and the 25th percentile (lower quartile - Q1). Therefore the IQR formula is:

IQR = Q3 - Q1

This equation is how to calculate IQR and is the interquartile range definition. On a box plot, the IQR is shown as the main body of the plot (the box's height). Here is an example of a box plot to demonstrate:

Box plot example showing upper quartile, lower quartile and the interquartile range
Box plot example showing upper quartile, lower quartile and the interquartile range.
(Ever.chae / CC BY-SA)

Here's another way to explain the upper and lower quartile values. The data is first divided in half at the median point. Take the lower part of the dataset and find its median value. That's the lower quartile value, Q1. To find the upper quartile, Q3, take the upper part of the data and find its median.

Don't confuse interquartile range with the similarly named range of a dataset. The range is the difference between the maximum and minimum values.

So, now that we've answered the question "What is interquartile range?", let's find out how to calculate it from a set of raw numbers.

How to find the interquartile range? - How to calculate IQR?

To find the interquartile range, we first have to find the upper and lower quartile values. This task isn't as straightforward as you would think, as Wikipedia lists four methods and the R programming language implements nine different ways.

In this IQR calculator we use method 4 listed on Wikipedia, which interpolates between data values. This interpolation is required if the quartile points fall between values in the dataset.

The first step in finding a quartile is to sort the data into numerical order. This sorting is required for all the different methods.

The second step is to calculate the rank of the upper and lower quartiles, using the following equations:

Lower quartile rank (LQR) = ¼(N + 1)
Upper quartile rank (UQR) = ¾(N + 1)

where N is the number of values in the dataset.

If the rank is a whole number, then the quartile is simply the corresponding value. For example, if the LQR result is 3, then the lower quartile is the 3rd value in the ranked list of values.

However, it is likely that the rank result will be a decimal number and therefore will not match up to a value from the dataset. The interpolation method takes the fractional component of the rank and multiplies it by the difference between the value corresponding to the whole number of the rank and the next ranking value. In equation form, finding the lower quartile looks like this:

Q1 = xLQR_int + LQR_frac(xLQR_int+1 - xLQR_int)

where:

  • x is a value from the ranked list with the subscript indicating the rank;
  • LQR_int is the whole number part of the LQR; and
  • LQR_frac is the decimal fraction (the part after the decimal point) of the LQR.

The formula for Q3 is similarly:

Q3 = xUQR_int + UQR_frac(xUQR_int+1 - xUQR_int)

It's probably best to illustrate these equations with a simple interquartile range example calculation. Let's say a ranked dataset consists of the values 5, 7, 8, 9, and we would like to find the lower quartile. The lower quartile rank is first calculated by:

LQR = ¼(N + 1) = (4 + 1) / 4 = 1.25

Therefore, LQR_int is 1 and LQR_frac is 0.25. We can now plug these numbers into the equation for Q1:

Q1 = x1 + 0.25 * (x2 - x1) = 5 + 0.25 * (7 - 5) = 5.5

So, we now have a value for the lower quartile range - 5.5. Now we use the same method to find the upper quartile:

UQR = ¾(N + 1) = (3/4) * (4 + 1) = 3.75

Q3 = x3 + 0.75 * (x4 - x3) = 8 + 0.75 * (9 - 8) = 8.75

Having found values for Q1 and Q3, we can calculate the interquartile range using the IQR formula:

IQR = Q3 - Q1 = 8.75 - 5.5 = 3.25

How to use this calculator to find the IQR

Using this calculator to find the interquartile range of a dataset of up to 50 values is super easy.

  1. Enter the values from the dataset, one value per row. The calculator requires a minimum of four values before a result is displayed.
  2. As you enter the values, rows will magically appear for you to add another value.
  3. Once you have entered a minimum of four values, the results for interquartile range (IQR), Q1, and Q3 are instantly displayed. They will update as you enter more data values.
Steven Wooding