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.

0 10 20 30 40 50 60 ngoại lai 48 Lớp A Q1=15 med=21,5 Q3=27 Lớp B Q1=24 med=30 Q3=38
Two box plots drawn on the same scale answer three questions that a raw data table cannot answer as quickly. First, class B has a median of $30$ compared with $21.5$ for class A, so B is ahead at the middle level. Second, B's box is wider: $\text{IQR}_B=38-24=14$ compared with $\text{IQR}_A=27-15=12$, so B is more spread out in the middle half. Third, and this is where the figure says something that the mean hides, class A has a value of $48$ beyond the whisker, drawn as a red cross. It is an outlier by the $1.5\times\text{IQR}$ rule: the upper fence is $Q_3+1.5(12)=27+18=45$, and $48>45$. Note the practical consequence: the mean of class A is $23.1$ while the median is only $21.5$; that gap is entirely due to the single value $48$ pulling it up. If you reported only the mean and did not draw the box plot, class A would look close to class B, while the figure shows that most learners in class A are actually well below.

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.

Common mistake

First trap: using class boundaries in place of midpoints when computing the mean of a grouped table. The error is exactly half the class width, uniform across every class, so the result still “looks nice” and nothing gives it away. Second trap: adding a constant to the standard deviation. For $y=3x-7$, the mean follows both operations ($\bar y=3\bar x-7$) but the standard deviation follows only the multiplication ($\sigma_y=3\sigma_x$); subtracting $7$ does not make the data any less spread out. Third trap: drawing the box plot whisker all the way to the outlier. Once a point has been separated out as an outlier, the whisker must stop at the next extreme value, otherwise marking the outlier means nothing. Fourth trap, and the most expensive one in modeling problems: thinking a large sample size cures bias. A survey of $10\,000$ people on a gaming forum still says nothing about the general population; the fault lies in the sampling frame, and no value of $n$ can fix it. When the problem asks you to “comment on the sampling method”, the answer that earns marks always talks about the frame and the way of selecting, not the quantity.

Key takeaway

Three numbers summarizing a data set answer three different questions: where is the center (mean or median), how spread out is it (standard deviation or IQR), and are there any unusual values (the $1.5\times$IQR rule). Choose the median-IQR pair when there are outliers, the mean-standard deviation pair when there are none; and always be able to state the sampling method before saying anything about the population.

← Voronoi diagrams, perpendicular bisectors and graph theory · All IB Math AI lessons · Practice IB Math AI questions (free, instant scoring) · Bivariate data: scatter diagrams, regression and correlation →