Statistics Mode
The mode is the value (or values) that appear most often in a dataset, and it is the only measure of central tendency that also works for categorical data.
What Is the Mode?
The mode is simply the most frequently occurring value in a dataset. Unlike the mean and median, which require numbers you can order or add, the mode can be found for any kind of data, including labels like colors or brand names.
Finding the Mode by Hand
A shoe store records the sizes sold in one day: 7, 8, 8, 9, 9, 9, 10, 11. Counting how often each size appears shows that size 9 was sold three times, more than any other size, so the mode is 9.
Example
shoe_sizes = [7, 8, 8, 9, 9, 9, 10, 11]
counts = {}
for size in shoe_sizes:
counts[size] = counts.get(size, 0) + 1
print(counts)
# {7: 1, 8: 2, 9: 3, 10: 1, 11: 1}
mode = max(counts, key=counts.get)
print("Mode:", mode)
# Mode: 9Example
import statistics
shoe_sizes = [7, 8, 8, 9, 9, 9, 10, 11]
print("Mode:", statistics.mode(shoe_sizes))
# Mode: 9
tshirt_sizes = ["S", "M", "M", "L", "L", "XL"]
print("All modes:", statistics.multimode(tshirt_sizes))
# All modes: ['M', 'L']Unimodal, Bimodal, and Multimodal Data
- Unimodal: exactly one value appears more often than all the others (like the shoe size example above).
- Bimodal: two values are tied for the highest frequency.
- Multimodal: more than two values are tied for the highest frequency.
- No mode: every value appears the same number of times, so no single value stands out.
A clothing shop sells T-shirts in these sizes over a day: S, M, M, L, L, XL. Both M and L were sold exactly twice, tied for the most frequent size, so this dataset is bimodal with modes M and L.
Exercise: Statistics Averages
Which measure of central tendency is most affected by extreme outliers?