Sampling, summary statistics and outliers
IB Math AI · Statistics and Probability
Sampling
Five techniques appear in AI, and each is defined by how the list is used, not by how large the sample is. Simple random: every subset of the given size is equally likely. Systematic: choose a random start, then take every $k$-th item, with $k=\dfrac{N}{n}$. Stratified: split into strata and sample each in proportion to its size. Quota: fill fixed counts per category, but choose non-randomly within them. Convenience: take whoever is available.
Only the first three are random. Quota and convenience samples carry bias that no sample size can remove.
Summary statistics from a frequency table
$$\bar x=\frac{\sum f x}{\sum f},\qquad \sigma=\sqrt{\frac{\sum f(x-\bar x)^{2}}{\sum f}}$$For grouped data, $x$ is the midpoint of the class. The answer is an estimate, because the original values inside each class are no longer known.
Quartiles, IQR and outliers
$\text{IQR}=Q_{3}-Q_{1}$. A value is an outlier if it lies below $Q_{1}-1.5\,\text{IQR}$ or above $Q_{3}+1.5\,\text{IQR}$. On a box plot an outlier is drawn as a separate point and the whisker stops at the most extreme value that is not an outlier.
Linear transformations
If $y=ax+b$ then $\bar y=a\bar x+b$ and $\sigma_{y}=|a|\sigma_{x}$. Adding a constant shifts the centre but leaves every measure of spread unchanged — the whole data set moves together.
Worked example: estimating the mean and standard deviation from a grouped table
The weekly self-study time (hours) of $50$ learners is recorded as follows.
| Time | $0\le t<10$ | $10\le t<20$ | $20\le t<30$ | $30\le t<40$ | $40\le t<50$ |
|---|---|---|---|---|---|
| Number of learners | $4$ | $11$ | $18$ | $9$ | $8$ |
Estimate the mean and standard deviation, then identify the class containing the median.
Solution
Step 1: take the midpoint of each class. This is the decisive step, and also the only one that can go wrong while the result still looks reasonable.
$$x=5,\ 15,\ 25,\ 35,\ 45$$Step 2: the mean.
$$\bar t=\frac{4(5)+11(15)+18(25)+9(35)+8(45)}{50}=\frac{20+165+450+315+360}{50}=\frac{1310}{50}=26.2\ \text{hours}$$Step 3: the standard deviation. Enter the table into the GDC as a list of values and a list of frequencies, then read $\sigma_{x}$:
$$\sigma=11.6\ \text{hours}$$Step 4: the class containing the median. The cumulative frequencies are $4,\ 15,\ 33,\ 42,\ 50$. The median is at position $25.5$, and positions $16$ to $33$ all lie in the class $20\le t<30$. So the median lies in the class $20\le t<30$.
Why this is only an estimate. A grouped table has thrown away the original values; we assume every learner in a class sits exactly at the midpoint. If in reality the $18$ learners of the middle class were all bunched at $21$ hours, the true mean would be noticeably lower than $26.2$, and the table gives no way to know that.
Two common errors, both giving reasonable numbers: using the lower boundaries $0,10,20,30,40$ in place of the midpoints gives $\bar t=21.2$, exactly $5$ hours lower, half the class width; using the upper boundaries gives $31.2$, exactly $5$ hours higher. If your answer is $5$ hours away from the correct one, you have almost certainly made one of these two errors.
Worked example: quartiles, the 1.5 IQR rule and the effect of outliers
Test scores of $10$ learners: $12,\ 15,\ 15,\ 18,\ 21,\ 22,\ 24,\ 27,\ 29,\ 48$.
Calculate $Q_{1}$, the median, $Q_{3}$ and the IQR. Identify every outlier by the $1.5\times\text{IQR}$ rule, then compare the mean with the median and explain the difference.
Solution
Step 1: the quartiles. The data are already in order, $n=10$ so the median is the mean of the two middle values:
$$\text{median}=\frac{21+22}{2}=21.5$$The lower half is $12,15,15,18,21$ with median $Q_{1}=15$; the upper half is $22,24,27,29,48$ with median $Q_{3}=27$.
$$\text{IQR}=27-15=12$$Step 2: the two fences.
$$Q_{1}-1.5(12)=15-18=-3,\qquad Q_{3}+1.5(12)=27+18=45$$The value $48$ exceeds the upper fence $45$, so it is an outlier. No value is less than $-3$, so there is no outlier on the low side.
Step 3: mean versus median.
$$\bar x=\frac{12+15+15+18+21+22+24+27+29+48}{10}=\frac{231}{10}=23.1$$The mean $23.1$ is higher than the median $21.5$. The entire gap of $1.6$ marks is due to the single value $48$: remove it and the mean of the other $9$ numbers is $\dfrac{183}{9}=20.3$, a drop of $2.8$ marks, while the median moves only from $21.5$ down to $21$.
A lesson measured in numbers: the median is robust to outliers, the mean is not. That is why reports on income, house prices or waiting times always use the median: a single extreme value is enough to drag the mean away while saying nothing about the majority.
Note a technical point that often causes arguments: if the largest value were $45$, exactly on the fence, it is not an outlier, because the rule uses the strict “greater than”. IB papers usually avoid this borderline case, but if you meet it you must write out the reasoning.