Summarize data while preserving information about spread and unusual values.

Statistics basics

Learning objectives

  • Calculate and interpret mean and median.
  • Describe spread with range and standard deviation.
  • Identify a possible outlier.
  • Choose a summary that fits the data.

Compare summaries

import statistics

normal_days = [20, 22, 21, 23, 24]
with_outlier = normal_days + [90]

print(statistics.mean(with_outlier))
print(statistics.median(with_outlier))
print(statistics.pstdev(with_outlier))

The mean uses every value and is pulled toward the value 90. The median is the middle value after sorting and is less affected by one extreme observation. Standard deviation describes typical distance from the mean, but it does not explain why a value is unusual.

Practice

For [4, 5, 5, 6, 20], calculate the mean, median, range, and standard deviation. Write one sentence about which summary best represents a typical day and why.

Common mistakes

  • Calling correlation proof of causation.
  • Reporting a mean without the number of observations.
  • Removing an outlier without investigating it.
  • Comparing averages measured in different units.

Checkpoint

If a robot records 0 cm for a sensor failure, should that value be included in the mean? Explain what additional information you need.

See the Python statistics module documentation for the functions used here.