Quartile Calculator | Interquartile Range Calculator
Understanding Quartiles and Interquartile Range (IQR)
1. What are Quartiles?
Quartiles are values that divide a dataset into four equal parts after arranging the data in ascending order. Each quartile represents a boundary between portions of the dataset.
First Quartile (Q1) – 25th percentile:
- 25% of the data lies below Q1.
- Also called the Lower Quartile.
Second Quartile (Q2) – 50th percentile:
- 50% of the data lies below Q2.
- Same as the Median (x̃).
Third Quartile (Q3) – 75th percentile:
- 75% of the data lies below Q3.
- Also called the Upper Quartile.
These quartiles help understand the spread and distribution of data.
Quartiles in a Box Plot
A box plot (box-and-whisker plot) visually represents quartiles:
- The box spans from Q1 to Q3.
- The median (Q2) is a line inside the box.
- The whiskers extend to the minimum and maximum values.
2. How to Calculate Quartiles?
To find quartiles, follow these steps:
Step 1: Arrange the data in ascending order.
Ensure that the data is sorted before proceeding.
Step 2: Find the Median (Q2).
- If n (number of observations) is odd, the median is the middle value.
- If n is even, the median is the average of the two middle values.
Step 3: Find Q1 and Q3.
- Q1 (Lower Quartile) = Median of the lower half (data below Q2).
- Q3 (Upper Quartile) = Median of the upper half (data above Q2).
Example 1: Quartile Calculation (Odd n)
Dataset: 3, 7, 8, 12, 13, 14, 18, 21, 23 (n = 9, odd)
Find Q2 (Median):
- Middle value = 13 (5th value)
- So, Q2 = 13
Find Q1:
- Lower half = [3, 7, 8, 12]
- Median of lower half = (7 + 8) / 2 = 7.5
- So, Q1 = 7.5
Find Q3:
- Upper half = [14, 18, 21, 23]
- Median of upper half = (18 + 21) / 2 = 19.5
- So, Q3 = 19.5
Example 2: Quartile Calculation (Even n)
Dataset: 4, 6, 7, 8, 10, 12, 15, 18, 20, 24 (n = 10, even)
Find Q2 (Median):
- Middle values = 10, 12
- Q2 = (10 + 12) / 2 = 11
Find Q1:
- Lower half = [4, 6, 7, 8, 10]
- Median of lower half = 7
- So, Q1 = 7
Find Q3:
- Upper half = [12, 15, 18, 20, 24]
- Median of upper half = 18
- So, Q3 = 18
3. Interquartile Range (IQR)
What is IQR?
The Interquartile Range (IQR) is the range between Q1 and Q3. It represents the spread of the middle 50% of the data.
IQR = Q3 − Q1
Why is IQR Important?
- Measures statistical dispersion (spread of the middle 50% of data).
- Resistant to outliers, unlike standard deviation.
- Helps detect outliers using the 1.5 × IQR rule.
Example: IQR Calculation
Using the first example:
- Q1 = 7.5, Q3 = 19.5
- IQR = 19.5 - 7.5 = 12
Using the second example:
- Q1 = 7, Q3 = 18
- IQR = 18 - 7 = 11
4. Detecting Outliers with IQR
Outliers are extreme values that lie outside a reasonable range. The 1.5 × IQR Rule helps identify them.
Formula for Outliers:
Lower Bound = Q1 − (1.5 × IQR)
Upper Bound = Q3 + (1.5 × IQR)
Any value outside this range is considered an outlier.
Example: Finding Outliers
Using Q1 = 7.5, Q3 = 19.5, and IQR = 12:
- Lower Bound = 7.5 - (1.5 × 12) = 7.5 - 18 = -10.5
- Upper Bound = 19.5 + (1.5 × 12) = 19.5 + 18 = 37.5
Values outside [-10.5, 37.5] are outliers.
5. Applications of Quartiles and IQR
Quartiles and IQR are widely used in statistics, finance, machine learning, and data analysis.
1. Descriptive Statistics
- Helps summarize data distributions.
- Used in box plots to visualize data spread.
2. Outlier Detection
- Used in data cleaning and anomaly detection.
- In machine learning, removing outliers improves model accuracy.
3. Finance & Economics
- Used in income distribution analysis.
- Helps analyze stock market returns and risks.
4. Quality Control
- Used in manufacturing to detect defective products.
5. Medical Research
- Helps analyze patient recovery times, blood pressure levels, etc.
6. Summary
Concept | Definition | Formula |
---|---|---|
Q1 (Lower Quartile) | 25th percentile | Median of lower half |
Q2 (Median) | 50th percentile | Middle value of dataset |
Q3 (Upper Quartile) | 75th percentile | Median of upper half |
IQR (Interquartile Range) | Middle 50% spread | IQR = Q3 - Q1 |
Outlier Rule | Identifies extreme values | Lower Bound = Q1 - 1.5 × IQR Upper Bound = Q3 + 1.5 × IQR |