Finding the centre: mean, median, and mode, and when each one tells the truth.
In Day 2, we learned how to sort data by type and scale. Now that we know what kind of data we have, the next question is simple: how do we sum it all up in one number? That's what today's article is about.
Imagine someone hands you a dataset with 10,000 customer purchases in it. You can't just stare at 10,000 numbers and understand what's going on. You need one number, a single value that tells you where most of the data sits. That's the "centre" of your data.
That's exactly what measures of central tendency do. The three most common ones are the mean, median, and mode. You might think one of them should be enough, but each one does a different job. By the end of this article, you'll know when to use which one, and why.
Knowing the centre of your data is not the whole picture. You also need to know how spread out the data is. That's called dispersion, and it includes things like variance and standard deviation. We already touched on a few of these in Day 1 (standard deviation, IQR, MAD). Day 4 goes much deeper into them.
The mean is what most people just call the "average." It's the most commonly used measure of central tendency, and you calculate it by adding up all the values and dividing by how many values there are. For a population, it's written as the Greek letter μ (mu). For a sample, it's written as x̄ (x-bar).
Let's look at the heights (in cm) of 7 people: [150, 155, 160, 160, 170, 175, 180]
The mean uses every single value in the dataset. That's good and bad at the same time. If you change even one value, the mean changes too. That's why one weird, far-off number, an outlier, can throw the mean way off.
Let's see what happens when we add an 8th value to the same dataset:
| 8th value added | New mean |
|---|---|
| 170 (a normal height) | 165.0 |
| 500 (an outlier) | 206.25 |
With the outlier of 500, the mean jumps to 206.25. But look at the actual data: nobody in it is anywhere close to 206.25 cm tall. That's the big problem with the mean, and it's exactly why we need the median.
This is why "average income" numbers can be so misleading. Picture a city where 999 people earn $40,000 a year, and one billionaire earns $1,000,000,000. The mean income there would be over $1 million a year! But the typical person in that city still earns $40,000. The median would show that clearly, while the mean hides it. It's the same lesson as Day 1's $200K salary example, just at the scale of a whole city.
The median is the middle value once you sort your data from smallest to largest. It splits your data into two equal halves: half the values sit below it, half sit above it. The median only cares about position, which value is in the middle, not the actual size of the numbers. That's why outliers barely touch it.
Our same 7 heights, sorted: [150, 155, 160, 160, 170, 175, 180]. The middle (4th) value is 160. That's the median.
Now add an 8th value of 170: [150, 155, 160, 160, 170, 170, 175, 180]. The two middle values are 160 and 170, so the median is (160 + 170) / 2 = 165.
Now add an outlier of 500 instead: [150, 155, 160, 160, 170, 175, 180, 500]. The two middle values are still 160 and 170, so the median is still 165.
The median didn't move at all when the outlier showed up. That property has a name: robustness.
Use the median whenever your data has outliers or is skewed (lopsided), like income, house prices, or how long people wait for something. The median gives you a much more honest picture of what's "typical."
The mode is simply the value that shows up the most in your data. Unlike the mean and median, the mode works on both numbers and categories (words). In fact, it's the only one of the three that works on categorical data, the same kind of data Day 2 told you never to average.
A dataset's mode can look like one of these:
A bank keeps a list of its customers' education levels: [Bachelor's, Master's, High School, Bachelor's, PhD, Master's, Bachelor's, Bachelor's].
The mode here is Bachelor's, since it shows up 4 times, more than anything else. This is the only one of the three measures that even makes sense on this list. You can't add up degree names to get a mean, and there's no way to sort them and find a "middle" degree either.
[12, 15, 15, 18, 20, 20, 22, 25]
Both 15 and 20 show up twice, more than any other number here. That makes this bimodal. When you see bimodal data, it's often a clue that you're actually looking at two different groups mixed together in one column, like two different age groups, or two different kinds of customers.
One small heads-up if you run this yourself: newer versions of scipy and numpy print numbers a little differently. You'll see mode=np.int64(15) instead of the plain mode=15 that older tutorials show. Don't worry, it's still just the number 15. Only how it gets displayed changed, not what actually happened. It picked 15 because that's the smaller of the two tied values.
Mean and median aren't your only two choices. There's a middle option called a trimmed mean. Here's how it works: sort the data, cut off a set percentage from each end, then take the mean of what's left. It's still a real mean, you just remove the most extreme values first.
Cutting 12.5% off each end of 8 numbers means removing exactly 1 number from each side, so it drops the 150 and the 500. What's left gets averaged like normal. The result lands right next to the median. Either number tells you basically the same story here, but this one is still technically a mean, just a smarter one.
A lot of real scoring systems use this exact trick. Olympic judges trim the highest and lowest scores before averaging for exactly this reason. It keeps most of what makes a mean useful, while stopping one wild score from deciding the whole outcome.
This next part might be the most useful part of the whole article. Picking the wrong measure can lead you straight to the wrong conclusion.
| Measure | Best used when | Avoid when |
|---|---|---|
| Mean | Data is balanced, has no big outliers, and is interval or ratio scale | Data is skewed or has outliers |
| Median | Data is skewed, has outliers, or is ordinal | You need the result for other calculations that are built around the mean, like variance |
| Mode | Data is categorical, or you just want the most popular value | Data is continuous with no repeated values, since then there may be no mode at all |
Where the mean, median, and mode land compared to each other can actually tell you something about the shape of your data.
| Distribution shape | Typical relationship | What it means |
|---|---|---|
| Symmetric (normal) | Mean = Median = Mode | Data is balanced around the centre |
| Right-skewed (positive skew) | Mode < Median < Mean | A few very large values are pulling the mean right |
| Left-skewed (negative skew) | Mean < Median < Mode | A few very small values are pulling the mean left |
If the mean and median in your dataset are far apart, that's a strong sign your data is skewed. Go look for outliers. This is one of the first things good data scientists check when they start exploring a new dataset, a step that even has its own name: exploratory data analysis, or EDA.
Here's something most textbooks don't tell you: the "typical relationship" column above is just a rule of thumb, not a rule that always works. It holds up well for smooth, single-peak distributions. But a researcher named Paul von Hippel showed in 2005 that it breaks more often than most people think, especially with whole-number data or data that has more than one peak. So treat this table as a helpful clue, not a promise. If your mean and median are far apart, skew is a good first guess, but it's still worth looking at the actual shape of your data before deciding anything for sure.
An online store looks at how much each order was worth (in USD) over one month. Most orders are between $20 and $80. But a few big company orders of $5,000 or more show up in the same list.
| Metric | Value | Interpretation |
|---|---|---|
| Mean | $312.00 | Pulled way up by the bulk orders, not representative |
| Median | $47.00 | The typical customer spends $47, an accurate picture |
| Mode | $29.00 | The single most common order value |
If a junior analyst reported the mean ($312) as the "average order value," that could lead to some bad business decisions. A good data scientist always checks whether the mean and median are close to each other. If they're not, that gap is a warning sign that the mean is hiding something.
The mean, median, and mode aren't rivals fighting for the same job. They're a team, and each one tells you something different. In any real project, calculate all three and compare them. The gaps between them tell you just as much as the numbers themselves do.
Quick reference:
Three questions to test whether this stuck.
The data is probably right-skewed, most likely because one or a few expensive houses are pulling the mean upward. The median, $310,000, is the more honest number for describing a "typical" house in this set.
Because topping names are nominal data: there's no number to add up, and no meaningful order to find the middle of. The mode, the most commonly picked topping, is the only measure of central tendency that applies here.
It breaks down. A bimodal dataset can still be symmetric, with mean and median landing in the same spot in the middle. But there's no single mode, since two values are tied for most common. This is exactly the kind of case the "common oversimplification" callout above was warning you about: a simple rule running into a shape it wasn't built for.
Measures of Dispersion: range, variance, standard deviation, and IQR in depth. Because knowing the centre of your data is only half the story.