The interquartile range (IQR) is a measure of variability, or how spread out a data set is. It is calculated by subtracting the first quartile (Q1) from the third quartile (Q3).
$$IQR = Q3-Q1$$
It is a more robust measure of variability than the range because it is not affected by outliers.
To calculate the IQR, you first need to find the median of the data set. The median is the middle value of the data set when assorted in ascending order. If there are two middle numbers, the median is the average of those two numbers.
Once you have the median, you can find the first quartile and the third quartile.
First quartile (Q1):
- is the middle value of the lower half of the data
- For a data set with an odd number of values: Q1 is value in the middle
- For a data set with even number of values, Q1 is the average of the two middle value.
Third quartile (Q3):
- is the middle value of the upper half of the data set.
- For data set with odd number of values: Q3 is the value in the middle
- For a data set with even number of values, Q3 is the average of the two middle values
Once you have Q1 and Q3, you can calculate IQR as
$$IQR = Q3-Q1$$
Example:
Calculate IQR for the data:
2, 4, 5, 7, 9, 11, 13, 15, 17, 19
1. Find the median:
Assort numbers from smallest to largest
2, 4, 5, 7, 9, 11, 13, 15, 17, 19
Median = (9+11)/2 = 10
2. Find Q1 and Q3:
Half way the data lies below 10, and half lies above
The lower half: 2, 4, 5, 7, 9
Q1, the middle value of the lower half = 7
The upper half: 11, 13, 15, 17, 19
Q3, the middle value of the upper half = 15
3. Calculate the IQR:
$$IQR = Q3 - Q1$$
$$IQR = 15 - 7 = 8$$
Therefore, the IQR for the given dataset is 8.
The IQR can be visualized using a box plot. A box plot shows the median, Q1, Q3, and the range of the data.
```
+------------------------+
| | |
| | | |
|----------------|---|-----------------|
| | | | | |
+------------------------+
```
- The box: represents the middle 50% of data (between Q1 and Q3)
- The line in the box: represnts the median
- The ends of the box (whiskers): extend to the most extreme values that are not considered outliers
- The outliers: are values that are more than 1.5 times the IQR above Q3 or below Q1.
They are represented as individual points outside of the whiskers.
Boxplots are a useful tool for visually comparing the distributions of different data sets.
Interquartile range (IQR) is a measure of variability that is not affected by outliers.
It is calculated by subtracting the first quartile (Q1) from the third quartile (Q3).
IQR can be visualized using box plot.