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.

Shoe SizeFrequency
71
82
93
101
111

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: 9

Example

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.

Note: The mode is the only measure of central tendency that makes sense for nominal (categorical) data. You cannot compute a mean or median eye color, but you can absolutely say the mode - the most common eye color in a room - is brown.
Note: Python's statistics.mode() returns just the first mode it encounters when there is a tie. If you need every tied mode, use statistics.multimode(), available since Python 3.8.

Exercise: Statistics Averages

Which measure of central tendency is most affected by extreme outliers?