Skip to content

Mean, Median, Mode

Three ways to describe "the typical value." Each answers a different question, and using the wrong one leads to misleading reports. This is the most basic statistical skill — and the one most often done wrong.

Learning Objectives

  • Calculate and interpret mean, median, and mode
  • Know when each is the appropriate measure
  • Understand how skewness affects the choice
  • Detect misleading use of averages

Mean — The Arithmetic Average

The mean is the sum of all values divided by the count. It uses every data point.

import numpy as np
import pandas as pd
from scipy import stats

# Example: order values for 10 customers
orders = [89, 125, 149, 165, 189, 210, 245, 310, 389, 8500]

mean = np.mean(orders)
print(f"Mean: £{mean:,.2f}")   # £1,437.10

The problem: The £8,500 whale order pulls the mean to £1,437 — a value no "typical" customer actually represents.

# Mean is the "balance point" of the data
# Imagine each value as a weight on a seesaw — the mean is where the seesaw balances

Median — The Middle Value

The median is the value that splits the dataset in half: 50% of values are below, 50% above.

median = np.median(orders)
print(f"Median: £{median:,.2f}")  # £199.50

# For odd count: the middle element
# For even count: average of the two middle elements
sorted_orders = sorted(orders)
# [89, 125, 149, 165, 189, 210, 245, 310, 389, 8500]
# Middle two: 189 and 210 → (189 + 210) / 2 = 199.50

The median is £199.50 — far more representative of a typical customer than the £1,437 mean.

Median is robust to outliers — the whale customer barely affects it.


Mode — The Most Frequent Value

The mode is the value that appears most often. Useful for categorical data and discrete values.

# For continuous data: use rounded bins
prices = [19.99, 29.99, 29.99, 49.99, 49.99, 49.99, 99.99, 149.99]
print(stats.mode(prices, keepdims=True).mode[0])  # 49.99

# For categorical data
statuses = ["completed", "pending", "completed", "cancelled", "completed"]
print(pd.Series(statuses).mode()[0])  # "completed"

When to Use Which

Situation Best measure Why
Symmetric distribution (bell curve) Mean Uses all data, unbiased
Right-skewed (revenue, prices, income) Median Robust to extreme values
Left-skewed Median Same reasoning
Categorical data Mode Only measure that makes sense
Discrete data (sizes, ratings) Mode or Median Depends on the question
Multiple peaks (bimodal) Both peaks + mode Report the modes separately

Business rule

When mean and median differ by more than 20%, report both and explain the skewness. "Average customer spends £1,437 (median £200 — skewed by a few large corporate accounts)."


The Mean vs Median Gap as a Signal

import pandas as pd

df = pd.read_csv("orders_clean.csv")
df["total"] = df["quantity"] * df["unit_price"]

mean = df["total"].mean()
median = df["total"].median()
ratio = mean / median

print(f"Mean:   £{mean:,.2f}")
print(f"Median: £{median:,.2f}")
print(f"Ratio:  {ratio:.2f}x")

if ratio > 1.5:
    print("⚠ Large skew — consider reporting median instead of mean")
elif ratio < 0.8:
    print("⚠ Left skew — consider reporting median")
else:
    print("✓ Distribution is roughly symmetric — mean is appropriate")

Weighted Mean

Sometimes values have different importance — the weighted mean accounts for this.

# Sales weighted by volume (not a simple average of prices)
products = pd.DataFrame({
    "product": ["A", "B", "C"],
    "price": [10, 50, 200],
    "units_sold": [1000, 200, 50],
})

simple_avg = products["price"].mean()
weighted_avg = np.average(products["price"], weights=products["units_sold"])

print(f"Simple average price:   £{simple_avg:.2f}")   # £86.67
print(f"Weighted average price: £{weighted_avg:.2f}")  # £18.42 — reflects actual sales mix

A customer care team might report average handle time as 8 minutes (simple average across call types), but the weighted average (by call volume) might be 5 minutes because most calls are short and simple.


Practice Exercises

Warm-up 1. Calculate mean, median, and mode for a list of order values: [45, 89, 120, 89, 149, 299, 89, 450, 5000, 89]. 2. Which is the best measure of "typical order value" for this list, and why? 3. Calculate the mean and median of df["total"]. By how much do they differ?

Main 4. For each product category, calculate mean and median order value. Which categories have the largest gap between mean and median? 5. The CEO reports average customer tenure as 3.2 years. The median is 1.1 years. What might explain this gap, and which number should the marketing team use? 6. Calculate the weighted average unit price — where the weight is units sold.

Stretch 7. Build a function that takes a Series and returns: mean, median, mode, and a recommended measure with a brief justification based on the skewness ratio. 8. Use bootstrapping to estimate the 95% confidence interval for the median order value (resample with replacement 1000 times, compute median each time).


Interview Questions

[Beginner] What is the difference between mean, median, and mode?

[Mid-level] UK median salary is £28,000 but mean salary is £35,000. Explain this discrepancy and which number a policymaker should use when discussing "typical" wages.

[Senior] A product manager says "we grew average revenue per user by 12% last quarter." You check the data and see that the median ARPU actually fell by 3%. What might explain this, and what does it mean for the business?


← Agenda · Next: Variance and Standard Deviation →