Measures of Central Tendency
A measure of central tendency is a single value that represents the centre or "typical" value of a dataset. The three classical measures are the mean, median and mode.
1. Arithmetic Mean
Ungrouped data: Grouped data (frequency distribution):
Σx Σ(f × x)
x̄ = ──── x̄ = ──────────
n Σf
x̄ = sample mean, μ = population mean
x = individual value, f = frequency, n = number of observations
Worked example (ungrouped). Marks: 45, 52, 68, 74, 81
Σx = 45 + 52 + 68 + 74 + 81 = 320
n = 5
x̄ = 320 / 5 = 64
Worked example (grouped).
| Class interval | Frequency (f) | Mid-point (x) | f × x |
|---|---|---|---|
| 0–10 | 5 | 5 | 25 |
| 10–20 | 8 | 15 | 120 |
| 20–30 | 12 | 25 | 300 |
| 30–40 | 10 | 35 | 350 |
| 40–50 | 5 | 45 | 225 |
| Total | Σf = 40 | Σfx = 1020 |
x̄ = Σfx / Σf = 1020 / 40 = 25.5
Properties of the arithmetic mean:
- The sum of deviations from the mean is always zero: Σ(x − x̄) = 0
- The sum of squared deviations from the mean is minimum — Σ(x − x̄)² is smaller than for any other value
- It uses every observation, so it is affected by every value — including outliers
- Means of subgroups can be combined into a combined mean:
n₁x̄₁ + n₂x̄₂
x̄₁₂ = ──────────────
n₁ + n₂
Example: Section A (n=40, mean=62), Section B (n=60, mean=70)
x̄ = (40×62 + 60×70) / 100 = (2480 + 4200) / 100 = 66.8
Other Means
| Mean | Formula | Use for |
|---|---|---|
| Weighted mean | Σ(w·x)/Σw | Values of unequal importance (CGPA with credit weights) |
| Geometric mean | ⁿ√(x₁ × x₂ × … × xₙ) | Growth rates, ratios, index numbers |
| Harmonic mean | n / Σ(1/x) | Rates and speeds (average speed over equal distances) |
Relationship: for any positive dataset, AM ≥ GM ≥ HM (equality only when all values are identical).
# Weighted mean — CGPA calculation
subjects = [("DBMS", 8, 4), ("DA", 9, 3), ("OS", 7, 4), ("NLP", 10, 2)]
num = sum(grade * credits for _, grade, credits in subjects)
den = sum(credits for _, _, credits in subjects)
print("CGPA:", round(num / den, 2)) # CGPA: 8.15
# Geometric mean — average growth rate over 3 years: 10%, 25%, -5%
from statistics import geometric_mean
factors = [1.10, 1.25, 0.95]
g = geometric_mean(factors)
print("Average annual growth:", round((g - 1) * 100, 2), "%") # 9.35 %
# (the arithmetic mean of 10, 25, -5 = 10% would OVERSTATE the true growth)
2. Median
The median is the middle value when data is arranged in ascending order — it divides the dataset into two equal halves.
Ungrouped data:
n odd -> Median = value of the ((n+1)/2)th item
n even -> Median = mean of the (n/2)th and (n/2 + 1)th items
Grouped data:
(n/2 - cf)
Median = L + ───────────────── × h
f
L = lower boundary of the median class
n = Σf (total frequency)
cf = cumulative frequency of the class BEFORE the median class
f = frequency of the median class
h = class width
Worked example (ungrouped, odd n). 12, 7, 3, 15, 9 → sorted: 3, 7, 9, 12, 15 → n = 5 (odd) → position (5+1)/2 = 3rd → Median = 9
Worked example (ungrouped, even n). 3, 7, 9, 12, 15, 20 → n = 6 → mean of 3rd and 4th = (9 + 12)/2 = 10.5
Worked example (grouped). Using the table above (Σf = 40, so n/2 = 20):
| Class | f | Cumulative f |
|---|---|---|
| 0–10 | 5 | 5 |
| 10–20 | 8 | 13 |
| 20–30 | 12 | 25 ← first cf ≥ 20, so this is the median class |
| 30–40 | 10 | 35 |
| 40–50 | 5 | 40 |
L = 20, cf = 13, f = 12, h = 10
Median = 20 + ((20 - 13) / 12) × 10
= 20 + (7/12) × 10
= 20 + 5.83
= 25.83
3. Mode
The mode is the most frequently occurring value.
Grouped data:
(f₁ - f₀)
Mode = L + ────────────────────────── × h
(2f₁ - f₀ - f₂)
L = lower boundary of the modal class (the class with highest frequency)
f₁ = frequency of the modal class
f₀ = frequency of the class before it
f₂ = frequency of the class after it
h = class width
Worked example (grouped). Modal class is 20–30 (highest f = 12):
L = 20, f₁ = 12, f₀ = 8, f₂ = 10, h = 10
Mode = 20 + ((12 - 8) / (24 - 8 - 10)) × 10
= 20 + (4 / 6) × 10
= 20 + 6.67
= 26.67
A dataset may be unimodal (one mode), bimodal (two), multimodal (many), or have no mode at all.
Empirical Relationship
For a moderately skewed distribution:
Mode ≈ 3 × Median − 2 × Mean
Check with our grouped data:
3(25.83) - 2(25.5) = 77.49 - 51 = 26.49 ≈ 26.67 computed directly ✓
Effect of Skewness — Which Measure to Trust
The mean is dragged toward the long tail. This is why median income is always reported instead of mean income — a handful of billionaires would make the "average" income meaningless.
Comparison Table
| Basis | Mean | Median | Mode |
|---|---|---|---|
| Definition | Sum ÷ count | Middle value | Most frequent value |
| Uses all data? | Yes | No | No |
| Affected by outliers? | Highly | No (robust) | No (robust) |
| Data types | Interval, Ratio | Ordinal, Interval, Ratio | All, including Nominal |
| Uniqueness | Always unique | Always unique | May not exist / may be multiple |
| Further algebra | Possible | Not really | Not really |
| Best for | Symmetric numeric data | Skewed data, data with outliers | Categorical data |
import pandas as pd
import numpy as np
salaries = pd.Series([25000, 28000, 30000, 32000, 35000, 38000, 2500000])
print("Mean: ", round(salaries.mean(), 2)) # Mean: 384000.0
print("Median:", salaries.median()) # Median: 32000.0
print("Mode: ", salaries.mode().tolist()) # every value unique -> all listed
print("Skewness:", round(salaries.skew(), 3)) # 2.645 strongly right-skewed
# The mean says "average salary is 3.84 lakh" — but 6 of 7 employees earn under 40k.
# The MEDIAN of 32,000 is the honest summary here.
# Trimmed mean — a compromise: drop the extreme 10% from each end
from scipy import stats
print("Trimmed mean (10%):", round(stats.trim_mean(salaries, 0.1), 2))
# All three at once, on a full DataFrame
df = pd.DataFrame({
"marks": [45, 52, 68, 74, 81, 68, 90, 68],
"city": ["Delhi", "Noida", "Delhi", "Gurgaon", "Delhi", "Noida", "Delhi", "Noida"],
})
print("Mean marks: ", df["marks"].mean()) # 68.25
print("Median marks:", df["marks"].median()) # 68.0
print("Mode marks: ", df["marks"].mode()[0]) # 68
print("Mode city: ", df["city"].mode()[0]) # Delhi (mean/median invalid here)
print(df["marks"].describe())
Central tendency tells you where the data sits. The next lesson answers the equally important question: how spread out is it?