Back to Learning Area

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

Plain Language

This preview is in Plain Language. The whole portal is also available in Plain Language. You can change the language at the top. Or use the button below. Our Plain Language texts are AI-assisted and editorially reviewed. They follow the core principles of easy-to-read language, but they are not certified Easy Read: a review panel of people with learning difficulties does not test them.

Preview: Understanding average and median

What is a dataset?

A dataset is a collection of values. For example: salaries in a company. Each single value is a data point. Many data points together are the dataset.

Average and median

The average adds all values together. Then it divides by the number of values. A very high value changes it strongly. The median is the middle value of a sorted list. It barely changes with extreme values.

When do I use what?

Use the median for salaries or prices. There are often extreme values there. Use the average for even data. Sometimes median and average are very different. This shows: there are extreme values in the dataset.

"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

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

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

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 (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. 1. List all values32 + 35 + 38 + 40 + 42 + 45 + 48 + 55 + 120
  2. 2. Calculate the sum= 455
  3. 3. Divide by the count455 / 9
  4. 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

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

Mean (Average)

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

Median

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.

Controls
Input
Examples
Mean6.14Median6Mode8Count7Sum43
Sorted:3, 4, 5, 6, 8, 8, 9

Takeaways

Note

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.

Check

Quiz: Measures of Central Tendency

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

Check

Learning Goals

Can you explain this in your own words? Tick what you've got.

0 of 3 done