Skip to content

03-01: Exercises — Mean, Median and Mode

Notes reference: 03-01: Mean, Median and Mode


Q1: All four measures, odd n

Data: 7, 12, 4, 9, 12, 15, 6

Find the mean, median, mode, and midrange.

Solution

Sorted:  4  6  7  9  12  12  15         n = 7

Mean      = (4+6+7+9+12+12+15) / 7 = 65 / 7 = 9.286
Median    = position (7+1)/2 = 4th value = 9
Mode      = 12   (appears twice)
Midrange  = (4 + 15) / 2 = 9.5
=AVERAGE(A2:A8)     ' 9.2857
=MEDIAN(A2:A8)      ' 9
=MODE.SNGL(A2:A8)   ' 12
=(MIN(A2:A8)+MAX(A2:A8))/2   ' 9.5

Q2: All four measures, even n

Data: 22, 18, 25, 30, 18, 27, 24, 29

Solution

Sorted:  18  18  22  24  25  27  29  30      n = 8

Mean      = 193 / 8 = 24.125
Median    = average of the 4th and 5th values = (24 + 25)/2 = 24.5
Mode      = 18
Midrange  = (18 + 30)/2 = 24

Check: with n even you always average the two middle values — never pick one.


Q3: Resistance to an outlier

Data: 20, 22, 24, 26, 28. Now change the last value to 128 and recompute.

Solution

Original With outlier Change
Mean 120/5 = 24.0 220/5 = 44.0 +20.0
Median 24 24 0.0
Mode none none
Midrange (20+28)/2 = 24 (20+128)/2 = 74 +50.0
The MEDIAN did not move at all — it is RESISTANT.
The MIDRANGE moved most, because it is built entirely from the two extremes.

Q4: Which measure would you report?

State the best measure of centre and justify it in one sentence.

  1. Typical house price in a city
  2. Most common shirt size ordered
  3. Average temperature in July across 31 days
  4. Typical time to complete a customer-support call, where a few calls run for hours
  5. Typical letter grade in a class (A, B, C, D, F)

Solution

1. MEDIAN   — house prices are strongly right-skewed; a few mansions
              drag the mean far above what a buyer would call "typical".
2. MODE     — shirt size is nominal/ordinal; you order stock by what sells most.
3. MEAN     — daily temperature is roughly symmetric with no wild outliers,
              and the mean uses all 31 values.
4. MEDIAN   — call durations are right-skewed with a long tail.
5. MEDIAN or MODE — letter grades are ORDINAL; a mean requires equal spacing
              between grades, which is not guaranteed.

Q5: Skewness from the mean and median

For each data set, state the likely skew and verify with Pearson's coefficient SK = 3(x̄ − median)/s.

Set median s
A 52.0 51.5 8.0
B 78.0 62.0 21.0
C 40.0 47.0 15.0

Solution

A   SK = 3(52.0 − 51.5)/8.0  = 3(0.5)/8.0   = +0.19   →  |SK| < 1
    APPROXIMATELY SYMMETRIC — mean ≈ median

B   SK = 3(78.0 − 62.0)/21.0 = 3(16)/21     = +2.29   →  SK ≥ 1
    STRONGLY RIGHT-SKEWED — mean pulled up by a long right tail

C   SK = 3(40.0 − 47.0)/15.0 = 3(−7)/15     = −1.40   →  SK ≤ −1
    STRONGLY LEFT-SKEWED — mean pulled down by a long left tail
=3*(AVERAGE(A2:A50)-MEDIAN(A2:A50))/STDEV.S(A2:A50)

Q6: Bimodal data

Data: 3, 5, 5, 7, 9, 9, 11

Find the mode(s), and explain what MODE.SNGL would hide.

Solution

5 appears twice.  9 appears twice.  →  BIMODAL: modes are 5 and 9.

MODE.SNGL(A2:A8)  returns only 5 — the first one it finds.
MODE.MULT(A2:A8)  spills BOTH 5 and 9.
stat_mode <- function(x) { t <- table(x); as.numeric(names(t)[t == max(t)]) }
stat_mode(c(3,5,5,7,9,9,11))     # 5 9
pd.Series([3,5,5,7,9,9,11]).mode()   # 0    5
                                     # 1    9

Why it matters: two modes often mean two mixed subgroups. Report both and consider splitting the data.


Q7: A trimmed mean

Data: 12, 14, 15, 16, 17, 18, 19, 20, 21, 95

Compute the mean, the median, and a 10% trimmed mean. Which best describes the typical value?

Solution

n = 10,  Σx = 247

Mean            = 247 / 10 = 24.7
Median          = (17 + 18)/2 = 17.5
10% trimmed     = drop the lowest 10% and highest 10% (one value from each end)
                = mean of  14, 15, 16, 17, 18, 19, 20, 21
                = 140 / 8 = 17.5

The mean of 24.7 exceeds NINE of the ten values — the single 95 owns it.
The median and the trimmed mean agree at 17.5, which is the honest answer.
=TRIMMEAN(A2:A11, 0.2)      ' 0.2 = 20% TOTAL, i.e. 10% from each end -> 17.5
mean(x, trim = 0.1)         # 17.5
from scipy import stats
stats.trim_mean(x, 0.1)     # 17.5

Q8: Conditional means

A data set has columns score and major. Compute the mean score for Biology majors only, and then the mean and median score for every major at once.

Solution

=AVERAGEIF($C$2:$C$101, "Biology", $E$2:$E$101)
=AVERAGEIFS($E$2:$E$101, $C$2:$C$101,"Biology", $D$2:$D$101,">=70")   ' two conditions

' All majors at once:  Insert ▸ PivotTable
'   Rows = major,  Values = score (set to Average), add score again (set to Count)
mean(students$score[students$major == "Biology"])

aggregate(score ~ major, data = students,
          FUN = function(x) c(n = length(x), mean = mean(x), median = median(x)))

library(dplyr)
students %>% group_by(major) %>%
  summarise(n = n(), mean = mean(score), median = median(score))
students.loc[students["major"] == "Biology", "score"].mean()

students.groupby("major")["score"].agg(["count", "mean", "median"])

Q9: The averaging trap

A store reports: "Our three branches averaged 82%, 76% and 88% customer satisfaction, so company-wide satisfaction is 82%." Branch sample sizes were 30, 25 and 45.

Is 82% correct?

Solution

NO. The plain average of 82, 76, 88 is (82+76+88)/3 = 82.0 — but that treats
the 45-customer branch as equal to the 25-customer branch.

The correct figure is the WEIGHTED mean:

  (30×82 + 25×76 + 45×88) / (30+25+45)
= (2460 + 1900 + 3960) / 100
= 8320 / 100
= 83.2%

The reported 82% understates satisfaction by 1.2 points because the
best-performing branch has the most customers.

Full treatment in 03-02.


⬅️ Previous: 02-02: Exercises — Graphical Displays ➡️ Next: 03-02: Exercises — Weighted and Grouped Means