Statistics Data Distribution
A data distribution shows how frequently each value or range of values occurs, revealing the overall shape, center, and spread of a data set at a glance.
What Is a Distribution?
A distribution is simply a description of how often each possible value shows up in a data set. Instead of staring at a long list of raw numbers, you group them and count how many times each value (or range of values) occurs. That grouped view is what lets you talk about a data set's shape.
Building a Frequency Table
Consider the number of coffees purchased in a single day by 20 customers at a small café: 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 6. Counting how many customers bought each amount gives us a frequency table.
Example: Building a Frequency Table
from collections import Counter
coffees_per_day = [1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 6]
frequency = Counter(coffees_per_day)
for value in sorted(frequency):
count = frequency[value]
bar = "*" * count
print(f"{value} cups: {count:>2} {bar}")
# Output:
# 1 cups: 2 **
# 2 cups: 5 *****
# 3 cups: 7 *******
# 4 cups: 4 ****
# 5 cups: 1 *
# 6 cups: 1 *Relative and Cumulative Frequency
Raw counts are useful, but proportions are often easier to compare across data sets of different sizes. The relative frequency is the count divided by the total number of observations. The cumulative frequency is a running total, which tells you how many observations fall at or below each value.
Example: Relative and Cumulative Frequency
from collections import Counter
coffees_per_day = [1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 6]
frequency = Counter(coffees_per_day)
n = len(coffees_per_day)
cumulative = 0
print(f"{'Value':>5} {'Freq':>5} {'RelFreq':>8} {'Cumulative':>11}")
for value in sorted(frequency):
count = frequency[value]
cumulative += count
rel_freq = count / n
print(f"{value:>5} {count:>5} {rel_freq:>8.2f} {cumulative:>11}")
# The cumulative column ends at 20, the full size of the data set,
# confirming every observation has been accounted for.Common Distribution Shapes
- Symmetric (bell-shaped): values cluster around a central peak, with roughly mirror-image tails on both sides.
- Skewed right (positive skew): most values are low, with a long tail stretching toward high values.
- Skewed left (negative skew): most values are high, with a long tail stretching toward low values.
- Uniform: every value or interval occurs with roughly equal frequency, so there is no clear peak.
- Bimodal: the data has two distinct peaks, often a sign that two different groups are mixed together.
Exercise: Statistics Data Distribution
What shape characterizes a normal distribution?