Descriptive statistics, outliers and linear transformations
IB Math AA · Statistics and Probability
Measures of centre and spread
The mean uses every value and is pulled by extreme ones; the median is the middle value and is not. For a frequency table, $\bar{x}=\dfrac{\sum fx}{\sum f}$, and the variance is
$$\sigma^{2}=\frac{\sum f\left(x-\bar{x}\right)^{2}}{\sum f}=\frac{\sum fx^{2}}{\sum f}-\bar{x}^{2}$$Quartiles, interquartile range and outliers
$\text{IQR}=Q_3-Q_1$. A value is treated as an outlier when it is more than $1.5\times\text{IQR}$ beyond $Q_1$ or $Q_3$:
$$x<Q_1-1.5\,\text{IQR}\qquad\text{or}\qquad x>Q_3+1.5\,\text{IQR}$$On a box plot the whiskers stop at the most extreme values that are not outliers; outliers are plotted individually.
Linear transformations
If $y=ax+b$ then
$$\bar{y}=a\bar{x}+b,\qquad \sigma_y=|a|\,\sigma_x,\qquad \sigma_y^{2}=a^{2}\sigma_x^{2}$$The constant $b$ shifts the centre but leaves every measure of spread unchanged.
Grouped data
With grouped data the individual values are lost, so the mean is estimated using the class midpoints, and the median is estimated by linear interpolation inside the class that contains the middle value.
Worked example: frequency table: mean, median, standard deviation
The table below records the number of times $30$ students were late in one month.
| Number of late arrivals $x$ | $0$ | $1$ | $2$ | $3$ | $4$ |
|---|---|---|---|---|---|
| Number of students $f$ | $5$ | $8$ | $10$ | $4$ | $3$ |
Find the mean, median and standard deviation.
Solution
Mean. $\sum f=30$ and
$$\sum fx=0(5)+1(8)+2(10)+3(4)+4(3)=0+8+20+12+12=52$$$$\bar{x}=\frac{52}{30}=1.733$$Median. With $n=30$, the median is the mean of the $15$th and $16$th observations. Cumulative frequencies: $5,\ 13,\ 23,\ 27,\ 30$. The $15$th and $16$th observations both fall in the group $x=2$ (this group spans from the $14$th to the $23$rd observation), so the median is $2$.
Standard deviation.
$$\sum fx^{2}=0+8+40+36+48=132$$$$\sigma^{2}=\frac{132}{30}-\left(1.733\right)^{2}=4.4-3.004=1.396\;\Longrightarrow\;\sigma=1.18$$Sensibility check: the data runs from $0$ to $4$, so the standard deviation must be smaller than half the range ($2$). If you get $4.4$, that is $\dfrac{\sum fx^{2}}{\sum f}$ — forgetting to subtract $\bar{x}^{2}$.
Worked example: outliers before and after a transformation
A data set has $Q_1=34$, median $46$, $Q_3=58$, minimum value $12$ and maximum value $108$. Identify the outliers. Then each value is transformed by $y=2x+5$; state the new $Q_1$, $Q_3$, $\text{IQR}$ and say whether the outlier status changes.
Solution
Outlier thresholds. $\text{IQR}=58-34=24$ so $1.5\times\text{IQR}=36$:
$$\text{lower threshold}=34-36=-2,\qquad \text{upper threshold}=58+36=94$$The value $12$ is greater than $-2$ so it is not an outlier; the value $108$ is greater than $94$ so it is an outlier.
After the transformation $y=2x+5$. The transformation is increasing so it preserves order, hence the new quartiles are the images of the old quartiles:
$$Q_1'=2(34)+5=73,\qquad Q_3'=2(58)+5=121,\qquad \text{IQR}'=121-73=48$$Note $\text{IQR}'=2\times 24=48$: the factor $2$ multiplies in, while the $+5$ has no effect.
Does the outlier status change? The new upper threshold is $121+1.5(48)=193$, and the new maximum value is $2(108)+5=221>193$. Still an outlier.
This is no coincidence: a linear transformation multiplies all distances by the same factor $|a|$, so the ratio "distance from $Q_3$ divided by $\text{IQR}$" does not change. An outlier stays an outlier, and a normal value stays normal.