Skip to content
Statistics

How is the interquartile range calculated?

Q3 - Q1

datasciencetrivia.com

Card 1 of 259. Answer: Q3 - Q1

Created by santiviquez

About · Quizzes · History of AI · To suggest new questions or report an error send me a dm.

The longer answer

The interquartile range is the third quartile minus the first: IQR = Q3 − Q1. Q1 is the 25th percentile and Q3 the 75th, so the IQR measures the spread of the middle 50% of the data as a single number.

Sort the data and find the quartiles. For 1, 3, 4, 7, 8, 10, 12, 15, 20 the median is 8. Taking the median of each half, leaving out the middle value, gives Q1 = 3.5 and Q3 = 13.5, so IQR = 10. The default in NumPy and R interpolates instead: Q1 = 4, Q3 = 12, IQR = 8. Both conventions are valid, so check your tool's.

Interviewers ask why not use the standard deviation. The IQR ignores the top and bottom quarters, so it is robust: change 20 to 2,000 and the IQR stays put, while the standard deviation jumps from about 6 to 664. For normal data, IQR ≈ 1.35σ. Box plots, the 1.5 × IQR outlier rule and scikit-learn's RobustScaler use it.

All questions