Statistical measures

Mean, median, mode, range, variance and standard deviation.

Computer Science/Informatics Practices5 questions

The essentials

Statistical measures summarise a data set in a few numbers. Measures of central tendency (mean, median, mode) describe a typical value. Measures of variability (range, variance, standard deviation) describe how much the values are spread out.

Key points

  • Mean (x̄): sum of values ÷ number of values. For 4, 8, 6, 5, 3, 8: sum = 34, mean = 34 ÷ 6 ≈ 5.67.
  • Median: the middle value after sorting. For an odd count it is the middle value; for an even count it is the mean of the two middle values. Sorted 3, 4, 5, 6, 8, 8 gives median (5 + 6) ÷ 2 = 5.5.
  • Mode: the value that occurs most often. Here it is 8. A data set can have more than one mode.
  • Range: maximum − minimum. Here 8 − 3 = 5.
  • Variance (σ²): the mean of the squared deviations from the mean: σ² = Σ(x − x̄)² ÷ n.
  • Standard deviation (σ): the square root of the variance. It is in the same unit as the data.
  • Example: 2, 4, 4, 4, 5, 5, 7, 9 has mean 5; squared deviations add to 32; variance = 32 ÷ 8 = 4; standard deviation = 2.
  • In Python: import statistics, then statistics.mean(), statistics.median(), statistics.mode(), statistics.pvariance() and statistics.pstdev() (population formulas, dividing by n).
  • A small standard deviation means values are close to the mean; a large one means they are widely spread.

Exam tips

  • Always sort the data before finding the median.
  • If every value is increased by the same constant, the mean increases by that constant but the range, variance and standard deviation do not change.

Common mistakes

  • Forgetting to take the square root when asked for standard deviation.
  • Finding the median of unsorted data by picking the middle position directly.

Practice questions

Practice this topic