Interquartile Range Calculator Formula
Understand the math behind the interquartile range calculator. Each variable explained with a worked example.
Formulas Used
Interquartile Range (IQR)
iqr = q3 - q1Lower Fence (Q1 - 1.5*IQR)
lower_fence = q1 - 1.5 * (q3 - q1)Upper Fence (Q3 + 1.5*IQR)
upper_fence = q3 + 1.5 * (q3 - q1)Variables
| Variable | Description | Default |
|---|---|---|
q1 | First Quartile (Q1) | 25 |
q3 | Third Quartile (Q3) | 75 |
How It Works
How to Calculate the Interquartile Range
Formula
IQR = Q3 - Q1
Q1 is the value below which 25% of observations fall, and Q3 is the value below which 75% fall. The IQR captures the spread of the middle 50% of the data, ignoring extreme tails.
Outlier Fences
Values below Q1 - 1.5*IQR or above Q3 + 1.5*IQR are considered potential outliers by the Tukey fence rule.
Worked Example
A dataset has Q1 = 25 and Q3 = 75. Find the IQR and outlier fences.
- 01IQR = 75 - 25 = 50
- 02Lower Fence = 25 - 1.5 * 50 = 25 - 75 = -50
- 03Upper Fence = 75 + 1.5 * 50 = 75 + 75 = 150
- 04Any value below -50 or above 150 is a potential outlier
Frequently Asked Questions
Why use IQR instead of range?
The IQR is resistant to outliers because it only considers the middle 50% of the data, while the range depends on the two most extreme points.
What is the 1.5*IQR rule?
It is a common heuristic for flagging outliers. Points more than 1.5 times the IQR below Q1 or above Q3 are considered potential outliers. Using 3*IQR flags extreme outliers.
How do I find Q1 and Q3?
Sort the data, then Q1 is the median of the lower half and Q3 is the median of the upper half. Use the Quartile Calculator for automated computation.
Learn More
Guide
How to Calculate Percentiles and Quartiles
Learn how to calculate percentiles and quartiles from a dataset. This guide explains the percentile rank formula, the interquartile range, and how these measures describe data distribution.
Ready to run the numbers?
Open Interquartile Range Calculator