Raw data is noise until you summarize it. Center (mean, median), spread (standard deviation, IQR), and shape (skew, modality) compress a dataset into a few numbers. Visualizations like histograms and box plots make the structure visible.
Change a salary with its slider. The plot and summaries follow your changes. All amounts are fictional annual salaries.
One row per person; position shows salary
Mean ยท dashed line$60,000
Median ยท solid line$60,000
Your mean: $300,000 shared across 5 people = $60,000 each.
Same mean, different spread
Try these two groups. Both have a mean and median of $60,000.
Population standard deviation for these 5 people: $14,142. Larger means more spread around the mean.
Mean, median, mode
The mean is the arithmetic average. The median is the middle value when sorted. The mode is the most frequent value. The mean is sensitive to outliers; the median is robust.
# Mean, median, mode in Python
data = [2, 3, 5, 5, 7, 8, 12, 15, 22]
mean = sum(data) / len(data)
sorted_data = sorted(data)
n = len(sorted_data)
median = sorted_data[n // 2] if n % 2else (sorted_data[n//2 - 1] + sorted_data[n//2]) / 2fromcollectionsimport Counter
mode = Counter(data).most_common(1)[0][0]
print(f"Data: {data}")
print(f"Mean: {mean:.1f}")
print(f"Median: {median}")
print(f"Mode: {mode}")
Standard deviation and IQR
Standard deviation measures average distance from the mean. IQR (interquartile range) is Q3 minus Q1, covering the middle 50% of data. IQR is robust to outliers; standard deviation is not.
For two categorical variables, a contingency table (cross-tabulation) counts how often each combination occurs. Row and column proportions reveal the relationship between the variables.
OpenIntro covers histograms, dot plots, and intensity maps with the county dataset. We focus on the core numerical summaries. The original also introduces the concept of robust statistics (median vs. mean) with income distribution examples. Variance here uses Bessel's correction (n-1 denominator) for sample variance, matching the textbook convention.