Mathematics for Data ScienceNot Started
Mean, Median & Mode
The three measures of central tendency — what they are and when to use each
0%
Explanation
These three values all describe the "center" of a dataset, but in different ways.
Mean — the average. Add all values, divide by count. `` [2, 4, 4, 4, 5, 5, 7, 9] → mean = 40 / 8 = 5.0
Median — the middle value when sorted. If even count, average the two middle values. `` [2, 4, 4, 4, 5, 5, 7, 9] → median = (4+5)/2 = 4.5
Mode — the most frequent value. `` [2, 4, 4, 4, 5, 5, 7, 9] → mode = 4
When each matters:
- Mean: works well for symmetric data with no outliers
- Median: better when outliers exist (e.g. income data — one billionaire skews the mean)
- Mode: only useful measure for categorical data (e.g. most common shoe size)
Examples
Computing all three in Python
Python's statistics module handles all three
import statistics
data = [2, 4, 4, 4, 5, 5, 7, 9]
print(statistics.mean(data)) # 5.0
print(statistics.median(data)) # 4.5
print(statistics.mode(data)) # 4Next in Mathematics for Data Science
Variance & Standard Deviation