Skip to content
Tutorials Center
My learning

Topics

Lesson 16 of 86 ยท Averages, Ages and Everyday Arithmetic

Weighted Averages, Median and Mode

Learn weighted means for class results and prices, how to find the median and mode, and the mean-median-mode relation, with code to check each answer.

The plain average treats every value as equally important. Real data rarely is. A final exam may count for half of a course grade while a quiz counts for 5%. A class of 40 students should influence the school average more than a class of 10. When values carry different importance, we use a weighted average.

The mean is also not the only way to describe a "typical" value. The median is the middle value of sorted data, and the mode is the value that appears most often. Each one answers a slightly different question, and aptitude tests like to ask when each is the right choice. This lesson shows how to calculate all three, how they behave when data contains an extreme value, and the approximate relation between them.

Weighted average

Weighted average = (wโ‚xโ‚ + wโ‚‚xโ‚‚ + โ€ฆ) รท (wโ‚ + wโ‚‚ + โ€ฆ)

Each value x is multiplied by its weight w (how many items it stands for, or how much it counts), the products are added, and the total is divided by the total weight.

Class results

Three sections took the same test.

Section Students Average mark
A 40 72
B 35 64
C 25 80

The weights are the numbers of students. The total marks are 40 ร— 72 + 35 ร— 64 + 25 ร— 80 = 2,880 + 2,240 + 2,000 = 7,120. There are 100 students, so the overall average is 71.2.

A fast sense check: the overall average must lie between the lowest and highest group averages (64 and 80), and it will lean towards the largest group. Section A has the most students, and 71.2 is close to 72.

Prices and quantities

A shopper buys 3 kg of apples at 40 per kg and 5 kg of apples at 52 per kg. The average price per kg is (3 ร— 40 + 5 ร— 52) รท 8 = (120 + 260) รท 8 = 380 รท 8 = 47.50. This is not the simple average 46, because more kilograms were bought at the higher price.

Grade components

A course counts assignments for 20%, a midterm for 30% and the final exam for 50%. A student scores 80, 70 and 90 in them. Here the weights are percentages, and they add to 100, so the weighted average is 0.20 ร— 80 + 0.30 ร— 70 + 0.50 ร— 90 = 16 + 21 + 45 = 82.

flowchart LR
    A["Values and their weights"] --> B["Multiply each value by its weight"]
    B --> C["Add the products"]
    C --> D["Divide by the total weight"]

A weighted average is a sum of value x weight, divided by the sum of weights.

When there are only two groups, you can also use alligation from Mixtures and Alligation: the ratio of group sizes equals the opposite ratio of distances from the overall average.

Weighted averages in code

This script computes the weighted averages from the three examples above. Change a weight and see how the result moves.

JS Weighted average calculator

Press Run (or Ctrl + Enter) to see the console output here.

No output.

The median

The median is the middle value after sorting the data.

  • If the count is odd, the median is the middle item.
  • If the count is even, the median is the average of the two middle items.

Example (odd). Data: 12, 7, 15, 9, 20, 7, 11. Sorted: 7, 7, 9, 11, 12, 15, 20. There are 7 values, so the median is the 4th: 11.

Example (even). Data: 4, 8, 6, 10, 12, 6. Sorted: 4, 6, 6, 8, 10, 12. The two middle values are 6 and 8, so the median is (6 + 8) รท 2 = 7.

The most common mistake is forgetting to sort first. Another is to find the median position wrongly: for n values, the position of the middle item is (n + 1) รท 2.

The mode

The mode is the most frequent value. In 12, 7, 15, 9, 20, 7, 11 the mode is 7, which appears twice. A data set can have no mode (every value appears once), one mode, or several modes (4 appears twice, 6 appears twice, and 9 appears once: the data is bimodal, with modes 4 and 6).

Which one to use?

The three measures react differently to an extreme value (an outlier). Take the data 7, 7, 9, 11, 12, 15, 20, whose mean is 81 รท 7 โ‰ˆ 11.57, median 11 and mode 7. Replace 20 with 200. The mean jumps to 261 รท 7 โ‰ˆ 37.29, while the median stays at 11 and the mode stays at 7.

Measure Question it answers Weakness
Mean What is the total share per item? Pulled by extreme values
Median What is the middle item? Ignores how far the other values are
Mode What is the most common item? May not exist or may not be unique

So the median is a better summary of typical salary or house price in a town where a few values are huge, while the mean is best when you care about totals.

The mean-median-mode relation

For a moderately skewed set of data, statisticians use the approximate rule:

Mode โ‰ˆ 3 ร— Median โˆ’ 2 ร— Mean

It is an empirical rule, not an exact law, so aptitude questions state something like "for a moderately skewed distribution". Example. The mean is 30 and the median is 28. The mode is about 3 ร— 28 โˆ’ 2 ร— 30 = 84 โˆ’ 60 = 24. When the mean is greater than the median (as here), the data is stretched to the right, and the mode is the lowest of the three, so the order mode < median < mean is what you expect.

Compute all three

This script finds the mean, median and mode(s) of a data set, shows the effect of an outlier and applies the relation.

JS Mean, median and mode

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. Class X has 20 students with average 50, and class Y has 30 students with average 60. What is the combined average?

    Total = 20 x 50 + 30 x 60 = 1,000 + 1,800 = 2,800 for 50 students, so the average is 56. The simple average (55) is wrong.
  2. 2. What is the median of 14, 3, 9, 21, 6, 11?

    Sorted: 3, 6, 9, 11, 14, 21. The two middle values are 9 and 11, so the median is 10.
  3. 3. A course counts homework 25%, a project 25% and an exam 50%. A student scores 80, 90 and 70. What is the weighted grade?

    0.25 x 80 + 0.25 x 90 + 0.5 x 70 = 20 + 22.5 + 35 = 77.5.
  4. 4. For a moderately skewed distribution the mean is 42 and the median is 40. What is the approximate mode?

    Mode is about 3 x median - 2 x mean = 120 - 84 = 36.
  5. 5. Which measure is NOT changed when the largest value in a data set is replaced by a much larger one?

    The largest value moves, so the mean, total and range all change. The median depends only on the middle position, which does not change (provided the data has more than two values).

Summary

  • A weighted average multiplies each value by its weight, adds, then divides by the total weight.
  • Weights can be counts (students), quantities (kilograms) or percentages (grade components).
  • The median is the middle of sorted data; with an even count, average the two middle values.
  • The mode is the most frequent value, and a data set may have none or several.
  • Outliers affect the mean far more than the median or the mode.
  • For moderately skewed data, mode โ‰ˆ 3 ร— median โˆ’ 2 ร— mean.

Next: Problems on Ages, where unknown ages are found from clues about sums, differences and ratios.