Skip to content

Beginner: data foundations · Statistics made simple · topic 6 of 62 · 30 min

Types of data, and the centre: mean, median, mode

Explanation

Data is either numbers (counts or measurements) or categories (labels, sometimes with an order). To describe the "typical" value you use the mean (the average), the median (the middle value) or the mode (the most common value). When a few values are extremely large, like one huge salary, the median tells the truer story.

Why statistics?

A column of 10,000 numbers means nothing to a human. Statistics is a set of tools that squeezes a column into a few honest numbers: what is typical, how spread out the values are, and what is unusual. Descriptive statistics, the subject of this module, describes the data you have. Module 3 adds inferential statistics, which uses a sample to make careful claims about a bigger group.

Kinds of data

Before choosing a summary, know what kind of data a column holds. The kind decides which summaries make sense.

KindMeaningExamples
Numeric, discreteCounts: whole numbers you get by countingChildren in a family, orders per day, goals scored
Numeric, continuousMeasurements that can take any value in a rangeHeight, rainfall in mm, delivery time, salary
Categorical, nominalLabels with no natural orderCity, blood group, payment method (UPI, card, cash)
Categorical, ordinalLabels with an order, but the gaps are not equalT-shirt size S/M/L, rating poor/good/excellent, class 8/9/10
Careful: Numbers are not always numeric data. A PIN code or a roll number is a label written in digits. The "average PIN code" is meaningless, so treat such columns as categories.

Population and sample

The population is the whole group you care about, such as all voters in India. A sample is the part you actually measured, such as 2,000 voters in a survey. Usually you cannot measure everyone, so you summarise a sample and use it to estimate the population. Keep the difference in mind: it matters for the spread in the next topic.

The mean

The mean (the ordinary average) is the total divided by how many values there are. In words: add everything up, then share it out equally. It uses every value, which is its strength and its weakness, because one extreme value pulls it a long way.

The median

The median is the middle value after sorting. With an odd number of values it is the one in the middle; with an even number it is the average of the two middle values. Half the data is below it and half above, and extreme values barely move it.

python
salaries = [25, 28, 30, 32, 35, 40, 400]   # monthly salary, ₹ thousand, in a small company

mean = sum(salaries) / len(salaries)
print(round(mean, 2))   # 84.29

s = sorted(salaries)
print(s[len(s) // 2])   # 32
One owner's salary of ₹4 lakh pulls the mean up to about ₹84 thousand, though six of seven people earn ₹40 thousand or less. The median, ₹32 thousand, describes a typical employee.
python
def median(values):
    s = sorted(values)
    n = len(s)
    mid = n // 2
    if n % 2 == 1:
        return s[mid]
    return (s[mid - 1] + s[mid]) / 2

print(median([7, 1, 5]))         # 5
print(median([40, 10, 30, 20]))  # 25.0
For four values the two middle ones after sorting are 20 and 30, so the median is 25.0.

Skew and outliers

An outlier is a value far away from the rest. A distribution is skewed when one side has a long tail. Salaries, house prices and delivery times are usually right-skewed: most values are modest and a few are very large. In right-skewed data the mean is bigger than the median. That is why reports on income usually give the median.

Think of it like this: Imagine a bus with 40 passengers whose average wealth is modest. A billionaire gets on. The average wealth on the bus jumps enormously, but the typical passenger is no richer. The median passenger barely changes.

The mode

The mode is the value that appears most often. It is the only one of the three that works for nominal data: the most common payment method, the most sold shoe size. A column can have two modes (bimodal) or more. Python's statistics.mode returns the first one it meets in the data, and statistics.multimode returns all of them as a list.

python
import statistics

sizes = [8, 9, 8, 10, 7, 8, 9]
print(statistics.mean(sizes), statistics.median(sizes), statistics.mode(sizes))   # 8.428571428571429 8 8

print(statistics.multimode(["UPI", "cash", "UPI", "cash", "card"]))   # ['UPI', 'cash']
The library versions, for checking your own. Two payment methods tie, so multimode returns both.

Which one to use

  • Mean: numbers without extreme values, or when the total matters (average bill, average marks).
  • Median: skewed numbers or data with outliers (salaries, house prices, delivery times).
  • Mode: categories, or the most common exact value (popular size, top payment method).

Common mistakes

  • Reporting only the mean of skewed data. Fix: report the median too, and say why they differ.
  • Forgetting to sort before taking the middle value. Fix: always use sorted(values) first.
  • Averaging labels such as PIN codes or ratings coded 1–5 without thinking. Fix: check the kind of data first; for ordinal ratings the median or the share of each rating is often clearer.
  • Treating 0 as missing, or missing as 0. Fix: remove or mark missing values before averaging.

Need help?

Stuck on a word or an idea? Search this course, or every course, and jump straight to the explanation or a worked question.

Try:

Watch the lesson

Types of data, and the centre: mean, median, mode · 1/7

Mean · Median · Mode

In this lesson you will learn the kinds of data, and the three ways to describe a typical value: the mean, the median and the mode.

Prefer a video by a teacher? Find free videos on “mean median mode types of data statistics for beginners” on YouTube ↗

In real life: Salary reports and job portals

Salary surveys and job portals usually show a median salary for a role, not the mean, because a few very high packages would make the mean misleading. When a college says "average package ₹12 LPA", a careful reader asks for the median too: a handful of large international offers can lift the average far above what most students receive.

python
packages = [4.5, 5, 5, 6, 6.5, 7, 8, 45]   # ₹ LPA, made-up placement offers

mean = sum(packages) / len(packages)
s = sorted(packages)
median = (s[3] + s[4]) / 2
print(round(mean, 2), median)
Output: 10.88 6.25. The "average package" looks almost twice the typical offer.

Practice (0/3 done)

Task 1 · Code · Python

Without the statistics module, write mean_of(values) that returns the mean of a list of numbers rounded to 2 decimal places. Return None for an empty list.

Task 2 · Code · Python

Without the statistics module, write median_of(values). Sort a copy of the values (do not change the input list). For an odd count return the middle value; for an even count return the average of the two middle values. Return None for an empty list.

Task 3 · Code · Python

Without the statistics module, write mode_of(values) that returns the most common value. If several values tie for the highest count, return the SMALLEST of them. Return None for an empty list.

Quick quiz

Question 1

1.Which of these is ordinal data?

Question 2

2.Monthly salaries in a team are mostly ₹30–40 thousand, plus one of ₹5 lakh. Which summary best describes a typical salary?

Question 3

3.What is the median of [12, 3, 9, 6]?

Question 4

4.Which summary can you use for the column "payment method" (UPI, card, cash)?

Question 5

5.In right-skewed data such as house prices, how do the mean and median usually compare?

Read more (free)

Open a question to see the answer and why. The first ones are this topic's own quiz, so try the quiz above before you peek.

Which of these is ordinal data?

Answer: Customer rating: poor, good, excellent

The ratings have a natural order, but the gaps between them are not measured, so they are ordinal.

Monthly salaries in a team are mostly ₹30–40 thousand, plus one of ₹5 lakh. Which summary best describes a typical salary?

Answer: Median

The median ignores how far out the one huge salary is; the mean is pulled up by it.

What is the median of [12, 3, 9, 6]?

Answer: 7.5

Sorted: 3, 6, 9, 12. The two middle values are 6 and 9, and their average is 7.5.

Which summary can you use for the column "payment method" (UPI, card, cash)?

Answer: Mode

Nominal labels have no order and no arithmetic, so only the most common value (the mode) makes sense.

In right-skewed data such as house prices, how do the mean and median usually compare?

Answer: The mean is bigger

The long tail of very expensive houses pulls the mean above the median.

marks = [40, 50, 90]. What is statistics.median(marks)?Related

Answer: 50

Sorted, the middle value of 40, 50, 90 is 50. The mean would be 60.

From Counting and grouping: collections and statistics

What is statistics.median([10, 20, 1000])?Related

Answer: 20

The median is the middle value after sorting: 20. One huge value does not pull it up.

From CSV files and simple statistics

You surveyed 50 of a company's 5,000 employees and want to estimate the spread of all salaries. Which formula fits?Related

Answer: Sample SD, dividing by n − 1

The 50 people are a sample used to estimate the population, so Bessel's correction (n − 1) applies.

From Spread: range, variance and standard deviation

Why is the IQR often preferred to the range for skewed data?Related

Answer: It uses only the middle 50% of values, so extreme values do not distort it

The IQR ignores the top and bottom quarters, where outliers live.

From Percentiles, quartiles and outliers

Pass the quiz (60% or more) or mark this topic as done when you are ready.

Your progress is saved on this device only.

Next steps

  1. 4 more topics in “Statistics made simple” before its exam: Spread: range, variance and standard deviation, Percentiles, quartiles and outliers, The normal distribution and z-scores, Correlation: how two things move together.
  2. Module 2 exam: Statistics made simple · 14 questions · 25 min, without help. 5 topics of this module still to finish first.
  3. Then the next module, Probability and inference. 62 topics left in the course before the final exam.

← Previous: Writing data code that others can trust