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
Dataset
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
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
The Mean — The Balance Point
Arithmetic Mean (Average)
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.
Step-by-Step Calculation
Python: Calculate the Mean
Common Misconception
The Median — The Outlier-Proof Center
Median
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 the path “Computer Science Structures & Algorithms” about sorting and complexity pays off.
Normal: ≈ 50.6k € | Extreme (120k → 1M): ≈ 148,333 € — Explodes with outliers. Every value pulls at the result.
Normal: 42k € | Extreme (120k → 1M): 42k € — Unchanged! Only position matters, not outlier magnitude.
When the Average Lies
Python: The Divergence Test
Deep Dive: AI Connection
Common Misconception
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
Three Key Insights
Quiz: Measures of Central Tendency
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?