Contents/ Part II · Describing Data/ Chapter 8

Measures of Central Tendency

If you could keep just one number to describe a whole dataset, which would it be? That single "typical" value is what central tendency captures, and there is more than one good answer.

⏱️ ~12 min read
🐍 Notebook included
📊 Chapter 8

Welcome to Describing Data, where we start describing data. The first job is almost always to find its center: a single value that represents the whole. There are three classic answers, and knowing which one to use is half the skill.

A measure of central tendency is one number that summarizes the "typical" value of a dataset. The three most common are the mean, the median, and the mode.
1

The Mean (Arithmetic Average)

The mean is the everyday average: add up all the values and divide by how many there are. It acts as the balance point of the data, the spot where the values on either side even out.

x̄ = (x₁ + x₂ + … + xₙ) / n = (1/n) · Σ xᵢ

Strengths

Uses every value, has tidy math, and underlies most of statistics (variance, regression, and more).

⚠️

Weakness

Sensitive to outliers. One extreme value can pull the mean far from where most of the data sits.

2

The Median (The Middle)

Sort the values and the median is the one in the middle. With an even count, average the two middle values. Because it only cares about position, not size, the median ignores how extreme the outliers are.

🏠
Why house prices use the median

A single $20-million mansion barely nudges the median home price of a town, but it would yank the mean upward and misrepresent what a typical home costs. Skewed money data is almost always reported as a median.

3

The Mode (Most Frequent)

The mode is the value that appears most often. It is the only measure of center that also works for categorical data (you can't average "blue," but you can find the most common color). A dataset can have one mode, several, or none.

Numerical use

The most common shoe size a store sells, so it knows what to stock.

Categorical use

The most popular product category, or the most frequent survey answer.

Multimodal

Two peaks (bimodal) often hint that two different groups are mixed together.

A caution: with truly continuous data, no value usually repeats, so the mode is undefined or unstable (it can jump around depending on how you round or bin the values).

4

Which One Should You Use?

The shape of the data decides. In a symmetric, single-peaked distribution the mean, median, and mode line up. When the data is skewed, a long tail tends to drag the mean toward it, while the median stays closer to the bulk of the data:

Left-skewed mean < median < mode Symmetric mean = median = mode Right-skewed mode < median < mean mean median mode
📝
A useful rule of thumb, not a law

This mean/median/mode ordering is a strong tendency, not a guarantee. It can break for discrete, heavily-skewed, or multimodal data (a symmetric two-peaked distribution, for instance, has two modes and no single center). Use it as a quick read of skew, and always look at the actual distribution.

Use the mean when…
  • the data is roughly symmetric with no big outliers
  • you need it for further math (variance, regression)
  • example: average height of a class
Use the median when…
  • the data is skewed or has outliers
  • you want the "typical" middle value
  • example: household income, house prices

Use the mode for categorical data, or to report the single most common value.

✂️
A middle ground: the trimmed mean

Want the mean's use of every value but the median's resistance to outliers? The trimmed mean drops a fixed percentage of the highest and lowest values, then averages the rest. It's exactly how Olympic judging throws out the top and bottom scores, and how the U.S. inflation figure (CPI) is computed. Think of a robustness spectrum: midrange → mean → trimmed mean → median.

5

Three Kinds of Mean: AM, GM, HM

"The mean" usually means the arithmetic mean, but two other averages matter when you are combining the wrong kind of numbers. Use the one that matches what you are averaging:

MeanWhat it doesUse it forExample
Arithmetic (AM)Add up, divide by nGeneral "typical" value; quantities you sumAverage test score
Geometric (GM)nth root of the productGrowth rates, percentages, things that compoundAverage annual return
Harmonic (HM)Reciprocal of the mean of reciprocalsRates over equal distances or amounts of workAverage speed of a trip
📐
A fixed ordering: AM ≥ GM ≥ HM

For any set of positive numbers, the arithmetic mean is always the largest and the harmonic mean the smallest, with equality only when every value is identical. Picking the wrong mean does not just give a slightly different number, it answers a different question.

🚗
The classic trap

Drive somewhere at 30 km/h and back at 60 km/h. Your average speed is not 45 (the arithmetic mean), it is 40 km/h (the harmonic mean), because you spend more time at the slower speed. The notebook proves it.

6

A Note on Grouped Data

Sometimes you only have counts per range (a frequency table), not the raw values. You can still estimate the mean: treat each class by its midpoint and weight it by how many values fall in that class.

grouped mean ≈ Σ(midpoint × frequency) / Σ(frequency)

It is an estimate, since the midpoint stands in for every value in the class, but it is remarkably close when the classes are reasonably narrow.

⚖️
This is really a weighted mean

That formula is a weighted mean: each value counts according to a weight (here, its frequency). Weighted means are everywhere once you notice them. Your GPA weights each course grade by its credit hours, and a course grade weights each category (say homework 40%, midterm 30%, final 30%) by its percentage. The plain average is just the special case where every weight is equal.

7

Central Tendency in Machine Learning & AI

These three averages are not just for summary tables, they are wired into how models learn and how messy data gets cleaned. Which "center" a method targets quietly decides how it treats outliers.

MeasureWhere it shows up in MLWhy
MeanThe value that minimizes squared error (MSE); the default fill for missing numeric featuresLeast-squares regression predicts the conditional mean, which is why it, like the mean, is pulled by outliers
MedianThe value that minimizes absolute error (MAE); the robust fill for skewed featuresMedian-based losses and imputation resist the extreme values that would distort a mean
ModeThe fill for missing categorical features; the majority-class baseline a classifier must beatYou cannot average a category, so the most frequent label is the natural stand-in and the bar to clear
🤖
Choosing a loss is choosing a center

When a model trains on MSE it is chasing the mean and inherits its outlier-sensitivity; train on MAE and it chases the median, gaining robustness. The same mean-versus-median trade-off you weigh when summarizing a column reappears, unnamed, in the loss function. Picking one is an outlier policy.

8

Real-World Example: A Company Salary Roster

Central tendency earns its keep on money data, which is almost always right-skewed. This roster of 220 employees is a clean case: a handful of senior and executive salaries pull the mean well above the median, so the two tell different stories about "typical" pay, and the typical department and job level can only be a mode. The companion notebook works it end to end.

📂 Dataset · measures-of-central-tendency--salaries.xlsx

One row per employee: employee_id, department (5 teams), job_level (Junior, Mid, Senior, Lead), years_experience, and the salary to summarize, annual_salary (US dollars). The salary column is deliberately right-skewed, and the two categorical columns are there for the mode.

🐍

Bring it to life in Python

The companion notebook computes all three averages, shows an outlier wrecking the mean, separates mean from median under skew, demonstrates AM ≥ GM ≥ HM with real uses, and averages a frequency table.

📓 View Notebook (code & outputs) ▶ Open in Colab ⬇ View / Download on GitHub

View opens the rendered notebook instantly (no setup). Open in Colab runs & edits it live in your browser. To run locally, install numpy, pandas, matplotlib and launch jupyter notebook.

🎓 Key Takeaways

  • Mean, median, mode are three ways to capture the typical value of a dataset.
  • The mean is sensitive to outliers; the median is not. Report the median for skewed data.
  • Skew separates them: the tail pulls the mean toward it, away from the median.
  • The mode is the only center that works for categorical data.
  • AM ≥ GM ≥ HM: use arithmetic for sums, geometric for growth, harmonic for rates.
9

Practice Challenges

Five short challenges covering the chapter. Beginner to intermediate; try them on paper or in Python.

1

The three averages

For [4, 8, 6, 5, 8, 9, 8, 3], compute the mean, median, and mode.

Hint: sort first; the median is the average of the two middle values.
2

The outlier test

Start with [10, 12, 11, 13, 12], then add the value 100. Recompute the mean and median, and say which one the outlier affected more.

Hint: compare how far each one moved.
3

Read the skew

A class's exam scores have mean 72 and median 78. Is the distribution left-skewed, right-skewed, or symmetric? What does that say about the scores?

Hint: which side is the mean pulled toward?
4

Average a growth rate

Revenue grows 20% in year 1, 5% in year 2, and falls 10% in year 3. Find the average annual growth rate.

Hint: growth compounds, so use the geometric mean of the factors 1.20, 1.05, 0.90.
5

Mean from a frequency table

Response times have midpoints [10, 20, 30, 40] seconds with frequencies [2, 5, 8, 5]. Estimate the mean response time.

Hint: Σ(midpoint × frequency) ÷ Σ(frequency).
Check your work

A fully-worked solutions notebook walks through all five challenges in the same visual style. Try them yourself first, then compare.

📓 View Solutions ▶ Open Solutions in Colab ⬇ View / Download on GitHub
10

Quiz: Test Yourself

Eight quick questions on central tendency. Answer them, hit Check Answers, and keep refining until you score 100%. Your progress is saved, so you can hop back to the chapter and return anytime.