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.

Fundamentals 13 min Beginner May 10, 2026

"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

Dataset

AnalogyDefinition
Imagine a class test: 28 students take a math exam. Each score is a data point. The feature is "grade." The 28 students are your sample. All math students in the country would be the population. The teacher cannot test every student in the country — she works with her sample of 28.

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).

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.

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

Arithmetic Mean (Average)

AnalogyDefinition
Imagine a seesaw with nine equal weights placed at positions matching the salary values (32, 35, ... 120). The balance point — where the seesaw tips neither left nor right — is the mean. The weight at 120 is far to the right, pulling the balance point toward it, even though most weights sit between 32 and 55.

The seesaw analogy breaks at one point: a physical seesaw has limits (it tips over), 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.

Step-by-Step Calculation

1
List all values 32 + 35 + 38 + 40 + 42 + 45 + 48 + 55 + 120
2
Calculate the sum = 455
3
Divide by the count 455 / 9
4
Interpret the result ≈ 50.6 thousand euros — but not a single employee actually earns that!

Eight 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.

~55.600 €
Average Income Germany (2024) Gross annual salary of full-time employees — skewed upward by high salaries
~52.000 €
Median Income Germany (2024) Half earn more, half earn less — closer to the "typical" salary

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...

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 increasingly reports median income alongside average income for precisely this reason.

The Median — The Outlier-Proof Center

Median

AnalogyDefinition
Line up nine people from shortest to tallest. The person at position 5 has the median height. Now replace the tallest person with a 3-meter basketball player. The person at position 5 has not changed — the median is identical. The mean height, however, jumped upward.

The analogy breaks at scale: with millions of data points, you cannot "line them up" — you need sorting algorithms, which cost O(n log n) time. Here your knowledge from Path I.A about sorting and complexity pays off.

Mean (Average)

Normal: ≈ 50.6k € | Extreme (120k → 1M): ≈ 148,333 € — Explodes with outliers. Every value pulls at the result.

Median

Normal: 42k € | Extreme (120k → 1M): 42k € — Unchanged! Only position matters, not outlier magnitude.

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.

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.0

# 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 your model has a low MSE but high MAE, outliers in your predictions point to a problem.

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, median, and mode. 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.

Example datasets:
6.14Mean
6Median
8Mode
7Count
43Sum
Sorted:3, 4, 5, 6, 8, 8, 9

Takeaways

Three Key Insights

  1. A dataset is a structured sample — not objective reality. Always understand what your data represents before summarizing it.
  2. The mean is the balance point where every value pulls. A single outlier can drag it far from the "typical."
  3. 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.

Quiz: Measures of Central Tendency

Question 1 / 4
Not completed

What is the difference between the mean and the median?

Select one answer
Answer Key: 1) B · 2) B · 3) C · 4) B

Checkpoint

Learning Goals

  • What is the difference between a data point, a feature, a sample, and the population? How would you map these concepts to Python data structures (lists, dictionaries)?
  • Why can the "average income" of a country paint a distorted picture of the typical income situation? What role do outliers like very high manager salaries play?
  • In which type of data situation would you prefer the median over the mean? How can you quickly compare both values in Python to detect outliers or skew?