Interquartile Range (IQR): Complete Guide with Solved Exercises

Master IQR: calculation, interpretation, and applications in data analysis through 5 detailed exercises with comprehensive solutions.

Solution: Exercises 1 to 3
1 Basic IQR Calculation
Exercise 1
Find the IQR for the following dataset: 12, 15, 18, 20, 22, 25, 28, 30, 35, 40
Definition:

Interquartile Range (IQR): The difference between the third quartile (Q3) and the first quartile (Q1). It represents the range of the middle 50% of the data.

Quartiles: Values that divide the ordered dataset into four equal parts.

Q1 (First Quartile): The median of the lower half of the data.

Q3 (Third Quartile): The median of the upper half of the data.

Calculation Method:
  1. Sort the data in ascending order
  2. Find the median of the entire dataset
  3. Find Q1 (median of lower half)
  4. Find Q3 (median of upper half)
  5. Calculate IQR = Q3 - Q1
Step 1: Sort the data

Dataset: 12, 15, 18, 20, 22, 25, 28, 30, 35, 40 (already sorted)

Total values: n = 10

Step 2: Find the median

n = 10 (even number)

Median = Average of 5th and 6th values = (22 + 25) ÷ 2 = 23.5

Step 3: Find Q1 (First Quartile)

Lower half: 12, 15, 18, 20, 22 (first 5 values)

Q1 = Median of lower half = 18 (3rd value)

Step 4: Find Q3 (Third Quartile)

Upper half: 25, 28, 30, 35, 40 (last 5 values)

Q3 = Median of upper half = 30 (3rd value)

Step 5: Calculate IQR

IQR = Q3 - Q1 = 30 - 18 = 12

Q1

18

Q3

30

IQR

12

IQR = 12 (represents the middle 50% of the data)
Final Answer:

Q1: 18

Q3: 30

IQR: 12

Interpretation: The middle 50% of values range from 18 to 30.

Applied Rules:

• IQR formula: IQR = Q3 - Q1

• Quartile positions: Q1 at 25%, Q3 at 75% of sorted data

• Median division: Separates data into lower and upper halves

2 IQR for Odd Number of Data Points
Exercise 2
Calculate the IQR for the following dataset: 5, 8, 10, 12, 15, 18, 20, 22, 25
Statistical Considerations:

Odd number of values: When n is odd, the median is included in both halves when finding Q1 and Q3.

Median exclusion: In some methods, the median is excluded from both halves.

Step 1: Sort the data

Dataset: 5, 8, 10, 12, 15, 18, 20, 22, 25 (already sorted)

Total values: n = 9 (odd)

Step 2: Find the median

n = 9 (odd number)

Median = 5th value = 15

Step 3: Find Q1 (First Quartile)

Lower half: 5, 8, 10, 12 (values below median)

Q1 = Median of lower half = Average of 2nd and 3rd values = (8 + 10) ÷ 2 = 9

Step 4: Find Q3 (Third Quartile)

Upper half: 18, 20, 22, 25 (values above median)

Q3 = Median of upper half = Average of 2nd and 3rd values = (20 + 22) ÷ 2 = 21

Step 5: Calculate IQR

IQR = Q3 - Q1 = 21 - 9 = 12

Step 6: Verify the calculation

Q1 = 9 (25th percentile)

Q3 = 21 (75th percentile)

IQR = 12 (50% of data falls within this range)

Q1

9

Q3

21

IQR

12

IQR = 12 for dataset with odd number of values
Final Answer:

Q1: 9

Q3: 21

IQR: 12

Interpretation: The middle 50% of values range from 9 to 21.

Applied Rules:

• Odd n rule: Exclude median when finding Q1 and Q3

• Quartile calculation: Use same method as median for halves

• IQR consistency: Formula remains IQR = Q3 - Q1 regardless of n

3 IQR and Outlier Detection
Exercise 3
Using the dataset from Exercise 1 (12, 15, 18, 20, 22, 25, 28, 30, 35, 40), identify any outliers using the 1.5×IQR rule.
Outlier Detection:

1.5×IQR rule: Values below Q1 - 1.5×IQR or above Q3 + 1.5×IQR are considered outliers.

Outlier boundaries: Lower boundary and upper boundary define the acceptable range.

Outlier Detection Method:
  1. Calculate Q1, Q3, and IQR
  2. Calculate lower boundary = Q1 - 1.5×IQR
  3. Calculate upper boundary = Q3 + 1.5×IQR
  4. Identify values outside these boundaries
Step 1: Use previously calculated values

From Exercise 1: Q1 = 18, Q3 = 30, IQR = 12

Step 2: Calculate lower boundary

Lower boundary = Q1 - 1.5×IQR

Lower boundary = 18 - 1.5×12 = 18 - 18 = 0

Step 3: Calculate upper boundary

Upper boundary = Q3 + 1.5×IQR

Upper boundary = 30 + 1.5×12 = 30 + 18 = 48

Step 4: Check each data point

Dataset: 12, 15, 18, 20, 22, 25, 28, 30, 35, 40

All values are between 0 and 48

No values are below 0 or above 48

Step 5: Conclusion

Since all values are within the range [0, 48], there are no outliers in this dataset.

Lower Boundary: 0

Upper Boundary: 48

No outliers detected

No outliers found (all values within [0, 48])
Final Answer:

Lower boundary: 0

Upper boundary: 48

Outliers: None

Conclusion: All data points are within the acceptable range.

Applied Rules:

• Outlier boundaries: Q1 - 1.5×IQR and Q3 + 1.5×IQR

• Outlier definition: Values beyond these boundaries

• Systematic detection: Standard method for identifying outliers

IQR: Formulas and Applications
IQR = Q3 - Q1
Core Formula
Q1
25th percentile
First quartile
Q3
75th percentile
Third quartile
IQR
Q3 - Q1
Middle 50% range
Key Definitions:

Interquartile Range (IQR): The difference between the third quartile (Q3) and the first quartile (Q1), representing the range of the middle 50% of the data.

Quartiles: Three values that divide the ordered dataset into four equal parts, each containing 25% of the data.

Q1 (First Quartile): The median of the lower half of the dataset, also known as the 25th percentile.

Q3 (Third Quartile): The median of the upper half of the dataset, also known as the 75th percentile.

Outliers: Data points that fall significantly outside the overall pattern of the data, typically defined using the 1.5×IQR rule.

Complete Calculation Method:
  1. Data sorting: Arrange all values in ascending order
  2. Median identification: Find the middle value of the dataset
  3. Q1 calculation: Find median of lower half (values below overall median)
  4. Q3 calculation: Find median of upper half (values above overall median)
  5. IQR calculation: Subtract Q1 from Q3
  6. Outlier detection: Apply 1.5×IQR rule if needed
Tip 1: Always sort data before finding quartiles to ensure accuracy.
Tip 2: For even number of values, median is average of two middle values.
Tip 3: IQR is robust to outliers, making it a reliable measure of spread.
Tip 4: IQR only considers the middle 50% of data, ignoring extreme values.
Advantages: Resistant to outliers, focuses on middle 50% of data, useful for comparing spread between datasets.
Applications: Outlier detection, box plot construction, comparing data spread, quality control.
Essential Rules:

• IQR formula: IQR = Q3 - Q1

• Outlier boundaries: Lower = Q1 - 1.5×IQR, Upper = Q3 + 1.5×IQR

• Quartile positions: Q1 at 25%, Q3 at 75% of sorted data

• Even n: Median = average of two middle values

• Odd n: Median = middle value

Solution: Exercises 4 to 5
4 Comparing IQRs of Different Datasets
Exercise 4
Compare the spread of two datasets using IQR:
Dataset A: 10, 12, 15, 18, 20, 22, 25, 28, 30
Dataset B: 15, 18, 20, 22, 25, 27, 30, 35, 40
Spread Comparison:

Comparing IQRs: A larger IQR indicates greater variability in the middle 50% of the data.

Relative spread: IQR provides a standardized way to compare variability across datasets.

Step 1: Calculate IQR for Dataset A

Dataset A: 10, 12, 15, 18, 20, 22, 25, 28, 30

Median = 20 (5th value)

Lower half: 10, 12, 15, 18 → Q1 = (12 + 15) ÷ 2 = 13.5

Upper half: 22, 25, 28, 30 → Q3 = (25 + 28) ÷ 2 = 26.5

IQR_A = 26.5 - 13.5 = 13

Step 2: Calculate IQR for Dataset B

Dataset B: 15, 18, 20, 22, 25, 27, 30, 35, 40

Median = 25 (5th value)

Lower half: 15, 18, 20, 22 → Q1 = (18 + 20) ÷ 2 = 19

Upper half: 27, 30, 35, 40 → Q3 = (30 + 35) ÷ 2 = 32.5

IQR_B = 32.5 - 19 = 13.5

Step 3: Compare the IQRs

IQR_A = 13

IQR_B = 13.5

Dataset B has a slightly larger IQR (by 0.5 units)

Step 4: Interpret the comparison

Dataset B has slightly more variability in the middle 50% of its data

Both datasets have similar spread, but Dataset B is slightly more dispersed

Dataset A IQR

13

Dataset B IQR

13.5

Difference

0.5

Dataset B has slightly larger IQR (13.5 vs 13)
Final Answer:

Dataset A IQR: 13

Dataset B IQR: 13.5

Comparison: Dataset B has slightly more variability in the middle 50% of data.

Applied Rules:

• Spread comparison: Larger IQR indicates greater variability

• Standardized measure: IQR allows fair comparison across datasets

• Robust comparison: IQR is not affected by extreme values

5 Real-World Application
Exercise 5
A company tracks daily sales for 11 days: $1200, $1300, $1400, $1500, $1600, $1700, $1800, $1900, $2000, $2100, $5000. Calculate IQR and determine if the highest value is an outlier. What does this tell management?
Business Application:

Real-world context: Understanding how IQR can identify unusual patterns in business data.

Management implications: Outliers may indicate special circumstances requiring investigation.

Step 1: Sort the data

Dataset: $1200, $1300, $1400, $1500, $1600, $1700, $1800, $1900, $2000, $2100, $5000

Total values: n = 11 (odd)

Step 2: Find the median

n = 11 (odd)

Median = 6th value = $1700

Step 3: Find Q1

Lower half: $1200, $1300, $1400, $1500, $1600

Q1 = Median of lower half = $1400 (3rd value)

Step 4: Find Q3

Upper half: $1800, $1900, $2000, $2100, $5000

Q3 = Median of upper half = $2000 (3rd value)

Step 5: Calculate IQR

IQR = Q3 - Q1 = $2000 - $1400 = $600

Step 6: Check for outliers

Lower boundary = Q1 - 1.5×IQR = $1400 - 1.5×$600 = $1400 - $900 = $500

Upper boundary = Q3 + 1.5×IQR = $2000 + 1.5×$600 = $2000 + $900 = $2900

Check highest value: $5000 > $2900 → This is an outlier

Step 7: Management implications

The $5000 sale is significantly higher than typical daily sales

This may indicate a special event, seasonal factor, or exceptional performance

Management should investigate to understand the cause

Lower Boundary: $500

Upper Boundary: $2900

Outlier detected: $5000

IQR = $600, $5000 is an outlier (above $2900 boundary)
Final Answer:

Q1: $1400

Q3: $2000

IQR: $600

Outliers: $5000 is an outlier

Management insight: The $5000 sale is significantly above normal daily sales and warrants investigation.

Applied Rules:

• Outlier detection: Systematic approach using 1.5×IQR rule

• Business relevance: Outliers may indicate special opportunities or problems

• Decision making: IQR helps identify data points requiring attention

Comprehensive Guide: IQR Laws, Methods, Rules, and Definitions
IQR = Q3 - Q1
Core Formula
Key definitions:

Interquartile Range (IQR): A measure of statistical dispersion that represents the range between the first quartile (25th percentile) and the third quartile (75th percentile). It captures the middle 50% of the data.

Quartiles: Three values (Q1, Q2, Q3) that divide a ranked dataset into four equal parts, each containing 25% of the observations.

Q1 (First Quartile): The value below which 25% of the data falls; the median of the lower half of the dataset.

Q3 (Third Quartile): The value below which 75% of the data falls; the median of the upper half of the dataset.

Outlier Detection: Using IQR to identify data points that fall significantly outside the normal range of the dataset.

Complete calculation methodology:
  1. Data preparation: Sort all values in ascending order
  2. Median identification: Find the middle value of the entire dataset
  3. Half dataset creation: Divide data into lower and upper halves
  4. Q1 calculation: Find median of lower half
  5. Q3 calculation: Find median of upper half
  6. IQR calculation: Subtract Q1 from Q3
  7. Outlier detection: Apply 1.5×IQR rule if needed
Tip 1: Always sort data first - this is crucial for accurate quartile calculation.
Tip 2: For odd n, exclude the median when finding Q1 and Q3; for even n, include both middle values.
Tip 3: IQR is robust to outliers, making it more reliable than range for measuring spread.
Tip 4: IQR is commonly used in box plots to visualize data distribution.
Tip 5: A larger IQR indicates greater variability in the middle 50% of the data.
Advantages: Resistant to outliers, focuses on middle 50% of data, provides robust measure of spread, useful for comparing datasets.
Applications: Quality control, outlier detection, box plot construction, comparing data variability, statistical analysis.
Limitations: Ignores extreme values, less intuitive than range, may not capture multimodal distributions.
Essential formulas and rules:

• IQR formula: IQR = Q3 - Q1

• Outlier boundaries: Lower = Q1 - 1.5×IQR, Upper = Q3 + 1.5×IQR

• Quartile positions: Q1 at 25%, Q2 at 50%, Q3 at 75% of sorted data

• Even n rule: Median = average of two middle values

• Odd n rule: Median = middle value

Detailed Summary: IQR Mastery Guide
IQR = Q3 - Q1
Core Formula
Comprehensive Definitions:

Interquartile Range (IQR): A robust measure of statistical dispersion that represents the difference between the 75th percentile (Q3) and the 25th percentile (Q1). It captures the range of the middle 50% of the data, making it resistant to extreme values.

Quartiles: Three values that divide an ordered dataset into four equal parts. Q1 (first quartile) is the median of the lower half, Q2 (second quartile) is the overall median, and Q3 (third quartile) is the median of the upper half.

Robust Statistics: Statistical measures that are not significantly affected by outliers or extreme values. IQR is a robust measure of spread because it only considers the middle 50% of the data.

Outlier Detection: The systematic process of identifying data points that deviate significantly from the overall pattern of the dataset using statistical criteria.

Complete Calculation Process:
  1. Data organization: Sort all values in ascending order
  2. Median determination: Find the middle value of the dataset
  3. Dataset division: Split data into lower and upper halves
  4. Q1 calculation: Find the median of the lower half
  5. Q3 calculation: Find the median of the upper half
  6. IQR computation: Calculate IQR = Q3 - Q1
  7. Outlier analysis: Apply 1.5×IQR rule for outlier detection
Example 1 (Simple): Dataset [1, 2, 3, 4, 5, 6]: Q1=2, Q3=5, IQR=3. The middle 50% ranges from 2 to 5.
Example 2 (Advanced): Dataset [10, 20, 30, 40, 50, 60, 70, 80]: Q1=25, Q3=65, IQR=40. Large spread in middle 50%.
Common Mistake: Forgetting to sort data before finding quartiles - always sort first!
Memory Aid: "IQR" = "Inner Quartile Range" - it measures the inner 50% of the data.
Key Notes: IQR is resistant to outliers, focuses on middle 50%, useful for comparing spread between datasets, fundamental for box plot construction.
Takeaways: Larger IQR = more variability in middle 50%; IQR only considers middle values; robust alternative to range; essential for outlier detection.
Core Principles for Success:

• Always sort first: Sorting data is essential for accurate quartile calculation

• Understand odd/even rules: Different methods apply based on dataset size

• Focus on middle 50%: IQR represents the core of the data distribution

• Robust measurement: IQR is reliable even when outliers are present

• Practical applications: Use IQR for real-world data analysis and comparison

Questions & Answers

Question: Why is IQR considered more robust than the range as a measure of spread? What's the difference?

Answer: The key difference lies in what data values they consider:

  • Range: Maximum - Minimum (uses only 2 extreme values)
  • IQR: Q3 - Q1 (uses the middle 50% of data)

IQR is more robust because it completely ignores the extreme values (outliers) that can dramatically affect the range. For example, in a dataset [1, 2, 3, 4, 100], the range is 99 (heavily influenced by the outlier 100), but the IQR is only 2 (showing the actual spread of the middle values).

This makes IQR a more reliable measure of typical variability in the dataset.

Question: When calculating Q1 and Q3 for an odd number of data points, should I include the median in both halves or exclude it?

Answer: There are different conventions, but the most common approach is to exclude the median:

  • Find the median of the entire dataset
  • Exclude it when creating the lower and upper halves
  • Calculate Q1 as the median of the lower half
  • Calculate Q3 as the median of the upper half

For example, with dataset [1, 2, 3, 4, 5]: median = 3, lower half = [1, 2], upper half = [4, 5]. This ensures Q1 and Q3 are equidistant from the overall median and maintains symmetry in the quartile system.

This is the standard method used in most textbooks and statistical software.

Question: How do I interpret different IQR values when comparing datasets? What constitutes a "large" or "small" IQR?

Answer: IQR interpretation is relative, not absolute. Here's how to evaluate it:

  • Within same variable: A larger IQR indicates more variability in the middle 50%
  • Relative to data range: Compare IQR to the overall range of the dataset
  • Context-dependent: What's "large" depends on the variable being measured

For example, an IQR of $1000 might be small for annual incomes but large for daily expenses. Always consider the scale of your data and the practical significance of the differences.

When comparing datasets, the one with the larger IQR has more variability in its middle 50% of values, assuming similar scales of measurement.