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.
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.
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.
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.
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.
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).
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:
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.
- the data is roughly symmetric with no big outliers
- you need it for further math (variance, regression)
- example: average height of a class
- 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.
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.
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:
| Mean | What it does | Use it for | Example |
|---|---|---|---|
| Arithmetic (AM) | Add up, divide by n | General "typical" value; quantities you sum | Average test score |
| Geometric (GM) | nth root of the product | Growth rates, percentages, things that compound | Average annual return |
| Harmonic (HM) | Reciprocal of the mean of reciprocals | Rates over equal distances or amounts of work | Average speed of a trip |
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.
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.
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.
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.
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.
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.
| Measure | Where it shows up in ML | Why |
|---|---|---|
| Mean | The value that minimizes squared error (MSE); the default fill for missing numeric features | Least-squares regression predicts the conditional mean, which is why it, like the mean, is pulled by outliers |
| Median | The value that minimizes absolute error (MAE); the robust fill for skewed features | Median-based losses and imputation resist the extreme values that would distort a mean |
| Mode | The fill for missing categorical features; the majority-class baseline a classifier must beat | You cannot average a category, so the most frequent label is the natural stand-in and the bar to clear |
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.
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.
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 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.
Practice Challenges
Five short challenges covering the chapter. Beginner to intermediate; try them on paper or in Python.
The three averages
For [4, 8, 6, 5, 8, 9, 8, 3], compute the mean, median,
and mode.
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.
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?
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.
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.
A fully-worked solutions notebook walks through all five challenges in the same visual style. Try them yourself first, then compare.
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.