Tutorials References Exercises Videos Menu
Create Website Get Certified Upgrade

Statistics - Interquartile Range


Interquartile range is a measure of variation, which describes how spread out the data is.


Interquartile Range

Interquartile range is the difference between the first and third quartiles (Q1 and Q3).

The 'middle half' of the data is between the first and third quartile.

The first quartile is the value in the data that separates the bottom 25% of values from the top 75%.

The third quartile is the value in the data that separates the bottom 75% of the values from the top 25%

Here is a histogram of the age of all 934 Nobel Prize winners up to the year 2020, showing the interquartile range (IQR):

Histogram of the age of Nobel Prize winners with interquartile range shown.

Here, the middle half of is between 51 and 69 years. The interquartile range for Nobel Prize winners is then 18 years.



Calculating the Interquartile Range with Programming

The interquartile range can easily be found with many programming languages.

Using software and programming to calculate statistics is more common for bigger sets of data, as finding it manually becomes difficult.

Example

With Python use the SciPy library iqr() method to find the interquartile range of the values 13, 21, 21, 40, 42, 48, 55, 72:

from scipy import stats

values = [13,21,21,40,42,48,55,72]

x = stats.iqr(values)

print(x)
Try it Yourself »

Example

Use the R IQR() function to find the interquartile range of the values 13, 21, 21, 40, 42, 48, 55, 72:

values <- c(13,21,21,40,42,48,55,72)

IQR(values)
Try it Yourself »