Definition
These are the three measures of central tendency, meaning a typical value of a dataset. The mean is the sum divided by the count. The median is the middle value after sorting. The mode is the most frequent value.
In simple words
Five friends earn 20, 25, 30, 35 and 40 thousand rupees. The mean and median are both 30. Then a crorepati joins. The mean jumps massively, and now describes nobody in the group, while the median barely moves. That's why salary reports usually quote the median.
Overview
- Measures of central tendency summarise a whole set of numbers with one typical value.
- The mean adds all values and divides by how many there are.
- The median is the middle value after sorting; with an even count it is the average of the two middle values.
- The mode is the value that appears most often; a set can have no mode or several.
- Outliers pull the mean but barely move the median.
- Comparing mean and median reveals skew: mean above median means a long right tail.
Why it matters
It's usually the first thing you check on new data. Filling in missing values needs a choice between mean, median and mode. A large gap between mean and median warns you about outliers or skew before they damage a model.
Key terms
- Central tendency
- A single value that represents the centre or typical value of a data set.
- Mean
- The sum of the values divided by how many there are; also called the arithmetic average.
- Median
- The middle value once sorted; the average of the two middle values when the count is even.
- Mode
- The most frequent value; a data set can have several modes or none.
- Skewness
- Lack of symmetry: a long tail on one side pulls the mean towards it.
- Robust statistic
- A measure that changes little when outliers are added, such as the median.
Types
There are several kinds of average. Each describes the centre in a different way and suits different data.
1. Arithmetic mean
The sum of the values divided by their count.
- How it works: Add every value and divide by n; every value affects the result in proportion to its size.
- Example: Marks 60, 70, 80 and 90 have mean 300 ÷ 4 = 75.
- When to use it: Use it for symmetric data without extreme values, such as heights or test marks, and as the basis of many statistics like variance.
2. Median
The middle value of the sorted data.
- How it works: Sort the values and take the middle one, or the average of the two middle ones when n is even; half the data lies on each side.
- Example: Incomes of ₹20k, ₹25k, ₹30k, ₹35k and ₹5 lakh have median ₹30k, while the mean is over ₹1.2 lakh.
- When to use it: Use it for skewed data such as incomes, house prices and delivery times, where a few huge values would mislead the mean.
3. Mode
The most frequent value in the data.
- How it works: Count how often each value occurs and pick the highest count; data can be unimodal, bimodal or multimodal.
- Example: Shoe sizes sold in a shop: 7, 8, 8, 9, 8, 10 have mode 8.
- When to use it: Use it for categories and discrete counts, such as the most popular size or the most common complaint, where a mean makes no sense.
4. Weighted mean
A mean where some values count more than others.
- How it works: Multiply each value by its weight, add the products and divide by the sum of the weights.
- Example: A grade with theory 70% weight (score 80) and practical 30% weight (score 90) gives 0.7 × 80 + 0.3 × 90 = 83.
- When to use it: Use it when items differ in importance or size: credit-weighted grades, price indexes and averaging groups of different sizes.
5. Geometric and harmonic means
Special averages for rates: the geometric mean for growth factors and the harmonic mean for rates such as speeds.
- How it works: The geometric mean is the n-th root of the product; the harmonic mean is n divided by the sum of reciprocals.
- Example: Growth of 10% then 50% averages to √(1.1 × 1.5) − 1 ≈ 28.5% per year; the F1 score is the harmonic mean of precision and recall.
- When to use it: Use them for investment returns, population growth, average speeds and combining precision with recall.
Explained in detail
Three answers to "what is typical?"
Each measure of centre answers a slightly different question. The mean answers "if everything were shared equally, how much would each get?" It uses every value, which makes it informative but sensitive to extremes. The median answers "what value splits the data in half?" It ignores how far the extremes are, only that they are above or below. The mode answers "what happens most often?" and is the only one that works for categories such as favourite colour or most common error message.
Skew and the order of the three
In a symmetric distribution, such as heights of adults, the mean, median and mode sit close together. In a right-skewed distribution, with a long tail of large values, the mean is pulled furthest to the right, the median sits in between and the mode is lowest. Incomes, house prices, city populations, waiting times and the number of followers on social media are all strongly right-skewed. This is why official income statistics usually report the median: a few billionaires can raise the mean income of a country without changing what a typical household earns.
Choosing in practice
| Situation | Best measure | Reason |
|---|---|---|
| Marks in a fair test, roughly symmetric | Mean | Uses all the information |
| Salaries, prices, response times | Median | Robust to a few huge values |
| Shoe sizes stocked, most common complaint | Mode | Categories or the most frequent choice |
| Data with suspected errors | Median, then investigate | Errors distort the mean |
Where these appear in AI
- Filling missing values: replacing a blank with the column's mean or median is a common, simple fix, and the median is safer for skewed columns.
- Baselines: a regression model should beat simply predicting the mean every time; a classifier should beat predicting the mode (the majority class).
- Loss functions: predicting the mean minimises squared error, while predicting the median minimises absolute error, which is why the choice of loss changes what a model learns.
- Normalisation: subtracting the mean centres features around zero before training.
In Python, statistics.mean, statistics.median and statistics.mode work on lists, and NumPy offers np.mean and np.median for arrays. pandas gives df["col"].mean() and .median() and skips missing values automatically, a convenience that can also hide how much data is missing, so always check the count too.
How it works
| Measure | Affected by outliers? | Use it for |
|---|---|---|
| Mean | Yes, strongly | Symmetric numeric data, such as heights |
| Median | Barely | Skewed data, such as income and prices |
| Mode | No | Categories, such as the most common city |
Finding the median
- Sort the values.
- With an odd count, take the middle one.
- With an even count, average the two middle ones.
The maths
- The mean, read "x bar"
- How many values
- The weight of value i, such as an exam's credit hours
Data: 2, 3, 3, 5, 7, 40.
Mean = (2+3+3+5+7+40) / 6 = 60/6 = 10 Median = (3+5) / 2 = 4 Mode = 3
The mean of 10 is higher than five of the six values, because of the outlier 40. The median of 4 describes this data better.
In code
import statistics as st
data = [2, 3, 3, 5, 7, 40]
print("Mean:", st.mean(data))
print("Median:", st.median(data))
print("Mode:", st.mode(data))
without_outlier = data[:-1]
print("Mean without 40:", st.mean(without_outlier))
print("Median without 40:", st.median(without_outlier))Output
Mean: 10 Median: 4.0 Mode: 3 Mean without 40: 4 Median without 40: 3
Common mistakes
- Reporting only the mean for skewed data. Check the median too.
- Forgetting to sort before finding the median.
- Taking the mean of categories coded as numbers. The average of city codes means nothing.
Check yourself
Summary
- Mean: the average. Median: the middle. Mode: the most common.
- Outliers pull the mean, but barely move the median.
- A big gap between mean and median signals skew.
Finished reading?
Sources: NIST handbook, measures of location