What is the difference between mean, median, and mode, and when do you use each?
Understand the difference between mean, median, and mode, how outliers affect each, and when to use every measure of central tendency in data science.
Expected Interview Answer
Mean, median, and mode are three measures of central tendency: the mean is the arithmetic average, the median is the middle value when data is sorted, and the mode is the most frequently occurring value.
The mean uses every value and is ideal for symmetric data, but it is sensitive to outliers and skew. The median splits the data into two equal halves and is robust to outliers, making it the better summary for skewed distributions like income or house prices. The mode identifies the most common value and is the only measure that works for categorical data. Choosing the right one depends on the data's distribution and type.
- Mean captures the full magnitude of all values
- Median resists distortion from outliers and skew
- Mode works for categorical and multimodal data
- Together they reveal the shape of a distribution
- Comparing them signals skewness direction
AI Mentor Explanation
To rate a batter's season, the mean adds every innings and divides — but one unbeaten triple century inflates it. The median is the middle score once innings are sorted, showing the typical outing. The mode is the score they make most often. A big gap between mean and median reveals a few huge knocks dragging the average up.
Step-by-Step Explanation
Step 1
Sort or tally the data
Order the values for the median and count frequencies for the mode.
Step 2
Compute the mean
Add all values and divide by the count to get the arithmetic average.
Step 3
Find the median
Pick the middle value; for an even count, average the two central values.
Step 4
Identify the mode
Select the most frequent value; there may be none, one, or several modes.
Step 5
Choose based on distribution
Use the mean for symmetric numeric data, the median for skewed data, and the mode for categorical data.
What Interviewer Expects
- Clear definitions of all three measures
- Understanding that the mean is sensitive to outliers
- Knowing the median is robust and best for skewed data
- Recognising the mode is the only option for categorical data
- Ability to relate the three to distribution skewness
Common Mistakes
- Always defaulting to the mean regardless of skew or outliers
- Forgetting to average the two middle values for even-sized datasets
- Assuming every dataset has exactly one mode
- Using the mean on ordinal or categorical data
- Confusing 'no mode' with 'mode equals zero'
Best Answer (HR Friendly)
“The mean is the average, the median is the middle value, and the mode is the most common value. You use the mean for balanced data, the median when a few extreme values would distort the average, and the mode when the data is categories rather than numbers.”
Code Example
import numpy as np
from scipy import stats
incomes = [32, 35, 38, 40, 42, 42, 250] # one outlier
mean = np.mean(incomes)
median = np.median(incomes)
mode = stats.mode(incomes, keepdims=False).mode
print('Mean :', round(mean, 1)) # pulled up by 250
print('Median:', median) # robust middle value
print('Mode :', mode) # most frequent valueFollow-up Questions
- Why is the median preferred for reporting income?
- How do mean, median, and mode relate in a right-skewed distribution?
- Can a dataset have more than one mode?
- What is a weighted mean and when is it useful?
- How do outliers affect each measure differently?
MCQ Practice
1. Which measure is most robust to outliers?
The median depends only on the middle position, so extreme values barely affect it.
2. Which measure can be used with categorical (non-numeric) data?
The mode is the most frequent category and is the only central-tendency measure valid for nominal data.
3. In a right-skewed distribution, how do the measures typically order?
A long right tail pulls the mean above the median, which sits above the mode.
Flash Cards
Definition of mean — The arithmetic average: sum of all values divided by the count.
Definition of median — The middle value when data is sorted; average the two centre values if the count is even.
Definition of mode — The most frequently occurring value; a dataset can have zero, one, or many modes.
Best measure for skewed data — The median, because it resists distortion from outliers.
Only measure for categorical data — The mode.
Continue Learning
Related Interview Questions
What is standard deviation and how does it differ from variance?
easy
What is the difference between correlation and causation in data analysis?
easy
What is exploratory data analysis (EDA) and what does it involve?
easy
What is data science and how does it differ from data analytics and machine learning?
easy