Measures of Central Tendency: Where Is the Middle?
Three ways to find the "center" of data — and the entertaining question of which one is being dishonest right now.
"The average salary at this company is 50,600 euros." Sounds reasonable — until you realize most employees earn under 45,000 and a single manager’s salary pulls the number up. One word can hide the truth: "average."
Mean and median both claim to describe the "middle" of a dataset. But they answer fundamentally different questions — and choosing the wrong one can mislead you about what is "typical." In this article, you will learn what a dataset is, how the mean works as a balance point, and why the median often gives a more honest answer.
The Dataset — From Single Value to Collection
Definition
Dataset
Analogy
Definition
In tabular data, a feature corresponds to a column and a data point to a row. In Python, you can represent a dataset as a list (one feature) or as a list of dictionaries (multiple features).
Deep dive
Python: List vs. Dictionary
# One-dimensional: single feature
salaries = [32, 35, 38, 40, 42, 45, 48, 55, 120]
# Multi-dimensional: multiple features per data point
employees = [
{"name": "Anna", "salary": 32, "dept": "Support"},
{"name": "Ben", "salary": 120, "dept": "Management"},
...
]For the rest of this article, we will work with nine salaries in thousands of euros: [32, 35, 38, 40, 42, 45, 48, 55, 120]. Eight employees cluster between 32k and 55k. One outlier sits at 120k. This asymmetry is exactly what makes the choice between mean and median matter.
Caution
Common Misconception
"A dataset is objective reality." No. Every dataset is the result of a collection process — who was sampled, how measurements were taken, which values were excluded. The same population can produce very different datasets depending on the sampling method. For AI, this means: before training a model, you must understand what your data actually represents.
The Mean — The Balance Point
Definition
Arithmetic Mean (Average)
Analogy
Definition
The seesaw analogy breaks at one point: a physical seesaw has limits (its board ends somewhere), while a dataset can contain arbitrarily extreme values that shift the mean without any natural boundary. This break point highlights exactly the mean’s vulnerability.
Note
Step-by-Step Calculation
- 1. List all values32 + 35 + 38 + 40 + 42 + 45 + 48 + 55 + 120
- 2. Calculate the sum= 455
- 3. Divide by the count455 / 9
- 4. Interpret the result≈ 50.6 thousand euros — but not a single employee earns exactly that!
Seven out of nine employees earn less than the average. The single value of 120k pulls the mean away from the cluster. This is exactly what happens in national income statistics.
Average Income Germany (2025)
~64.400 €
Gross annual salary of full-time employees — skewed upward by high salaries
Median Income Germany (2025)
~54.100 €
Half earn more, half earn less — closer to the "typical" salary
Deep dive
Python: Calculate the Mean
salaries = [32, 35, 38, 40, 42, 45, 48, 55, 120]
mean = sum(salaries) / len(salaries) # 50.555...
# Or using the standard library:
import statistics
mean = statistics.mean(salaries) # 50.555...Caution
Common Misconception
"The average always describes the typical value." Only for roughly symmetric distributions. For skewed data (incomes, house prices, API response times under load), the mean can be far from what any "typical" data point looks like. Germany’s Federal Statistical Office also reports median income alongside average income for precisely this reason.
The Median — The Outlier-Proof Center
Definition
Median
Analogy
Definition
The analogy breaks at scale: with millions of data points, you cannot "line them up" — you need algorithms: sorting costs O(n log n) time, while special selection algorithms find the median in as little as O(n). Here your knowledge from the path “Computer Science Structures & Algorithms” about sorting and complexity pays off.
Normal: ≈ 50.6k € | Extreme (120k → 1M): ≈ 148.3k € — Explodes with outliers. Every value pulls at the result.
Normal: 42k € | Extreme (120k → 1M): 42k € — Unchanged! Only position matters, not outlier magnitude.
Caution
When the Average Lies
House prices, app download statistics, click counts, response times under load — wherever a few extreme values dominate the rest, the average paints a distorted picture. In practice: when mean and median diverge significantly, it is a warning signal for outliers or skewed distributions — and the median describes the "typical" more honestly.
Deep dive
Python: The Divergence Test
import statistics
salaries = [32, 35, 38, 40, 42, 45, 48, 55, 120]
mean = statistics.mean(salaries) # ≈ 50.6
median = statistics.median(salaries) # 42
# The gap reveals the skew:
print(f"Mean: {mean:.1f}, Median: {median}")
# Mean > Median → right-skewed (outlier pulls mean up)
# Replace CEO salary with 1,000 (= 1 million €):
salaries_extreme = [32, 35, 38, 40, 42, 45, 48, 55, 1_000]
print(statistics.mean(salaries_extreme)) # ≈ 148.3
print(statistics.median(salaries_extreme)) # 42 — unchanged!In AI practice, the choice between mean and median directly affects the loss function: Mean Squared Error (MSE) optimizes toward the mean, Mean Absolute Error (MAE) toward the median — despite having "Mean" in its name, MAE optimization mathematically converges to the median. MSE penalizes large errors disproportionately — good for symmetric data, bad when outliers dominate training. During data preprocessing, missing values are often imputed with the median rather than the mean, because the median is more robust to outliers. And during evaluation: if the RMSE (the square root of the MSE) is clearly higher than the MAE, some predictions are far off — a sign of outliers.
Caution
Common Misconception
"Mean and median are practically the same thing." For symmetric, clean data, yes. But for skewed distributions (incomes, house prices, app response times, click counts), they can differ dramatically. In AI, this affects your choice of loss function: MSE uses the mean, MAE uses the median. Choose wrong, and your model optimizes for the wrong "center."
Interactive: Compute Central Tendency
You have learned about mean and median; the third measure in the calculator, the mode, is simply the most frequent value. Enter your own data points and observe live how the three measures change. Try the outlier dataset — and see how a single extreme value shifts the mean while the median stays stable.
Takeaways
Note
Three Key Insights
- A dataset is a structured sample — not objective reality. Always understand what your data represents before summarizing it.
- The mean is the balance point where every value pulls. A single outlier can drag it far from the "typical."
- The median is the outlier-proof center: when it and the mean diverge, something interesting is happening in your data — outliers, skew, or a story worth investigating.
Check
Quiz: Measures of Central Tendency
What is the difference between the mean and the median?
Select one answer
1. What is the difference between the mean and the median?
2. Salaries: [30, 32, 35, 40, 42, 45, 48, 55, 200]. What happens to the mean and median if 200 increases to 500?
3. Average income of a city: 65,000 euros. Median income: 42,000 euros. What does this tell you?
4. One AI model uses Mean Squared Error (MSE), another uses Mean Absolute Error (MAE). Both predict house prices in a dataset with luxury outliers. Which model better predicts the typical price?
Checkpoint
Check
Learning Goals
Can you explain this in your own words? Tick what you've got.
0 of 3 done