Menu
×
   ❮   
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE
     ❯   

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 »

×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
[email protected]

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
[email protected]

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2024 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.