☰

Measures of Central Tendency

Measures of Central Tendency: Mean, Median and Mode with Examples

A shop owner says her customers spend about 500 rupees on a visit. A company says its staff earns about 66,900 rupees a month. Each sentence squeezes a whole list of numbers into one. That single number is called a measure of central tendency, and picking the right one decides whether the sentence is honest or misleading.

There are three main measures: the mean, the median and the mode. They often give different answers for the same data, and each is right in some cases and wrong in others. In data science you use them in the first hour with any dataset, to understand its typical value, before doing anything advanced.

This tutorial explains all three in plain steps. You will learn how to calculate each one for a plain list, a discrete frequency table and a continuous class table, how to avoid the usual mistakes, how to choose between them, and how to get the same answers in Python in a few lines.

What is Central Tendency?

Central tendency is a single value that describes the centre, or the typical value, of a set of data. It tells you where the data tends to gather. Other names are average and measure of central location.

Take the marks of five students: 72, 65, 81, 75 and 83. You can say that the class did well, but one number is easier to compare. If another class has a typical mark of 70, you can compare the two groups at once.

Measures of central tendency tutorial

Three Types of Data Series

How you calculate depends on how the data is arranged. You will meet three layouts.

The three types of data series
Series What it looks like
Individual series A simple list of values, such as 72, 65, 81, 75, 83
Discrete series Each value appears with its frequency, which tells you how many times it occurs. Example: value 10 occurs 2 times
Continuous series Values are grouped into classes, such as 10 to 20, with a frequency for each class

A Quick Example with Marks

The five marks add up to 376. Dividing by 5 gives 75.2, which is the mean. Sorted, the marks are 65, 72, 75, 81, 83, and the middle one is 75, which is the median. No mark repeats, so this list has no mode.

Measures of central tendency example with the marks of five subjects

Mean

The mean is what most people call the average. You add up all the values and divide by how many there are.

Mean of an Individual Series

Mean = sum of all values divided by the number of values. For the marks above, 376 divided by 5 is 75.2.

Types of measures of central tendency: individual series mean

Mean of a Discrete Series

When values repeat, multiply each value by its frequency, add the results, and divide by the total frequency. Write this as: mean = sum of f times x, divided by N. Here x is the value, f is its frequency, and N is the total of all frequencies. Note that N is not the frequency of one value. The live page calls N simply Frequency, which is misleading.

Types of measures of central tendency: discrete series mean

Example: the values are 10, 20, 30, 40 and 50, with frequencies 2, 5, 6, 9 and 4.

Mean of a discrete series: worked table
Value x Frequency f f times x
10 2 20
20 5 100
30 6 180
40 9 360
50 4 200
Total N = 26 860

Mean = 860 divided by 26 = 33.08 (to two decimal places). The live page says 33.07. The exact value is 33.0769, so rounding gives 33.08.

Mean of a Continuous Series

For classes, first find the midpoint of each class. Add the lower and upper limit, and halve it. Then use the same method with the midpoint as x. The result is an estimate, because you no longer know the exact values inside each class.

Measure of central tendency with example: continuous series mean

Example: the classes are 10 to 20, 20 to 30, 30 to 40, 40 to 50 and 50 to 60, with the same frequencies 2, 5, 6, 9 and 4.

Mean of a continuous series: worked table
Class Midpoint x Frequency f f times x
10 to 20 15 2 30
20 to 30 25 5 125
30 to 40 35 6 210
40 to 50 45 9 405
50 to 60 55 4 220
Total N = 26 990

Mean = 990 divided by 26 = 38.08. The live page says 38.07, and the exact value is 38.0769.

Median

The median is the middle value when the data is sorted from smallest to largest. Half the values lie below it and half lie above.

Median of an Individual Series

  1. Sort the values in order.
  2. Count them. Call the count N.
  3. If N is odd, the median is the value at position (N plus 1) divided by 2.
  4. If N is even, take the two middle values, at positions N divided by 2 and N divided by 2 plus 1, and find their average.

Odd example: 34, 41, 29, 52, 41, 47, 38, 60, 44. Sorted: 29, 34, 38, 41, 41, 44, 47, 52, 60. N is 9, the position is (9 plus 1) divided by 2 = 5, and the 5th value is 41. So the median is 41.

Even example: add one more value, 50, to get 10 values. Sorted: 29, 34, 38, 41, 41, 44, 47, 50, 52, 60. N is 10, so the middle sits between the 5th and 6th values, which are 41 and 44. The median is (41 plus 44) divided by 2 = 42.5. The live page writes N as 9 in this example, which is wrong. The data has 10 values.

Median of a Discrete Series

Build a cumulative frequency column, which is a running total of the frequencies. Find the first cumulative frequency that is greater than or equal to N divided by 2. The value on that row is the median.

Example (my own numbers): values 10, 20, 30, 40, 50 with frequencies 4, 7, 12, 9, 6.

Median of a discrete series: cumulative frequency
Value Frequency Cumulative frequency
10 4 4
20 7 11
30 12 23
40 9 32
50 6 38

N is 38, so N divided by 2 is 19. The first cumulative frequency that reaches 19 or more is 23, on the row for value 30. The median is 30. Expanding the list and taking the middle two values, the 19th and 20th, gives 30 and 30, so the answer holds.

Measure of central tendency example: discrete series median

Median of a Continuous Series

Here you first find the median class, then use a formula to place the median inside it.

Measure of central tendency: median of a continuous series
Median = L plus ((N divided by 2 minus Cf) divided by f) times h
  • L is the lower limit of the median class. The live page says upper limit, which is wrong.
  • N is the total frequency.
  • Cf is the cumulative frequency of the class just before the median class.
  • f is the frequency of the median class.
  • h is the width of the class.

Important Working Hints

  • The median class is the first class whose cumulative frequency is greater than or equal to N divided by 2. The live page says to pick the value numerically less than N1, which is not correct.
  • The classes must be continuous with no gaps. If they read 10 to 19, 20 to 29, correct them first, so that the limits touch.
  • Always sort the data first for an individual series.

Example from the original page: N = 170, so N divided by 2 is 85. The median class is 30 to 40. The cumulative frequency before it, Cf, is 59, the class frequency f is 50, and h is 10. Median = 30 plus ((85 minus 59) divided by 50) times 10 = 30 plus 5.2 = 35.2.

Measures of central tendency example: continuous series median

Mode

The mode is the value that appears most often. It is the only one of the three that also works for words and categories, such as the most common shirt size or the most popular course.

Mode of an Individual Series

Count how often each value occurs. The one with the highest count is the mode. Example: 2, 1, 3, 6, 6, 5, 1, 2, 2, 3. The value 2 appears three times, more than any other, so the mode is 2.

A list can have more than one mode. In 1, 2, 2, 3, 3, 4, both 2 and 3 appear twice, so the data is bimodal. If no value repeats, there is no mode.

Mode of a Discrete Series

Look at the frequency column. The value with the largest frequency is the mode.

Mode of Grouped Data

Find the modal class, which is the class with the highest frequency. Then use this formula:

Mode = l plus h times (f1 minus f0) divided by (2 times f1 minus f0 minus f2)
  • l is the lower limit of the modal class.
  • h is the class width.
  • f1 is the frequency of the modal class.
  • f0 is the frequency of the class before it.
  • f2 is the frequency of the class after it.

Example from the original page: the modal class is 30 to 40, so l is 30 and h is 10. The page works out to 30 plus 10 times (5 divided by 10) = 35. The formula is correct on the live page.

Mean, Median or Mode: Which One Should You Use?

This is the part most tutorials skip, and it matters more than the formulas. The mean uses every value, so one very large value drags it upwards. The median ignores how large the extremes are, so it stays steady.

Here is a worked case. Ten staff earn these monthly salaries in thousands of rupees: 22, 25, 27, 28, 30, 31, 33, 35, 38 and 400, where the last is the owner.

Salary example: how one outlier changes the mean and the median
Measure All ten people Without the owner
Mean 66.9 29.89
Median 30.5 30

One outlier lifted the mean from about 30 to 66.9. Almost nobody in the group earns that. The median moved from 30 to 30.5. If a company says its staff earns 66,900 a month on average, it is true, and it is also misleading. The median tells the fairer story.

Which measure to use and when
Measure Use it when Watch out for
Mean Data is fairly even, with no extreme values, and you need a number you can use in further calculations Outliers pull it away from the typical value
Median Data is skewed or has outliers, such as incomes, house prices or delivery times It ignores how large the extremes are
Mode Data is in categories, or you want the most common value There can be none, one or many

A habit worth building: calculate the mean and the median together. If they are close, the data is fairly balanced. If they are far apart, you have skew or outliers, and you should look at the data before trusting either.

Calculate Them in Python

You rarely do this by hand in real work. The statistics module comes with Python, and pandas gives the same answers for a column of data. I ran the code below and the output is real.

python
import statistics as st
import pandas as pd

marks = [72, 65, 81, 75, 83]
print("Mean:", st.mean(marks))
print("Median:", st.median(marks))

data = [34, 41, 29, 52, 41, 47, 38, 60, 44, 50]
print("Median of 10 values:", st.median(data))
print("Mode:", st.mode([2, 1, 3, 6, 6, 5, 1, 2, 2, 3]))
print("All modes:", st.multimode([1, 2, 2, 3, 3, 4]))

salary = [22, 25, 27, 28, 30, 31, 33, 35, 38, 400]
s = pd.Series(salary)
print("Mean:", s.mean())
print("Median:", s.median())

values = [10, 20, 30, 40, 50]
freq = [2, 5, 6, 9, 4]
n = sum(freq)
mean = sum(v * f for v, f in zip(values, freq)) / n
print("N =", n, " Mean =", round(mean, 2))
output
Mean: 75.2
Median: 75
Median of 10 values: 42.5
Mode: 2
All modes: [2, 3]
Mean: 66.9
Median: 30.5
N = 26  Mean = 33.08

Use mode for the first mode only, and multimode when a list may have more than one. The module also has other averages. The geometric mean suits growth rates, and the harmonic mean suits rates such as speed. For example, driving the same distance at 40 and 60 kilometres an hour gives a harmonic mean of 48, which is the true average speed. The plain mean of 50 would be wrong. These two are given by geometric_mean and harmonic_mean in the same module. For grouped data, there is median_grouped, which takes the class width as its interval argument.

Common Mistakes to Avoid

Common mistakes and the fix
Mistake Fix
Using N as the frequency of one value N is the total of all frequencies
Forgetting to sort before finding the median Always sort first
Using the position as the answer The position tells you where to look. The median is the value at that position
Using class limits instead of midpoints for the mean Use the midpoint of each class
Taking the lower limit of the wrong class in the median formula Use the median class, which is the first class where Cf reaches N divided by 2
Reporting the mean for skewed data without checking Compare it with the median
Rounding too early Keep full decimals and round the final answer

Practice Questions

  1. Find the mean and median of 12, 15, 11, 20, 18, 15.
  2. A list has the values 4, 4, 5, 6, 6, 7. Find all modes.
  3. Find the mean of the values 5, 10, 15 with frequencies 3, 4, 3.
  4. Ten people earn 20, 22, 24, 25, 26, 27, 28, 30, 31 and 300 (in thousands). Which measure describes them better, and why?

Answers: 1) Mean is 91 divided by 6 = 15.17 and the sorted list 11, 12, 15, 15, 18, 20 gives median (15 plus 15) divided by 2 = 15. 2) Modes are 4 and 6. 3) Sum of f times x is 15 plus 40 plus 45 = 100, N is 10, so the mean is 10. 4) The median, because the 300 is an outlier that pulls the mean up. These answers are my calculations, so please recheck them before publishing.

Mean, median and mode look simple, but choosing between them is a real skill. Practise on your own data. Calculate the mean and median side by side, and notice when they disagree. That habit will save you from many wrong conclusions in data science.

Popular Tags:

Measures of central tendency Measures of Central Tendency in Data Science Measures of central tendency tutorial Types of Measures of Central Tendency