Describe the distribution
Task 2 · mean versus median, spread, IQR and histogram bins
Week 2 summaries meet Week 6 histograms: one extreme value moves the mean but not the median, and bin edges change the picture but not the data.
Lab 6 PDF p. 2 · Task 2 (16 minutes)
Your task
Replace 40 with 400 and compare mean and median; compare two groups with equal means; compute IQR = 73.6 − 58.3; count the eight grades by hand, then plot them with two sets of bin edges.
Evidence to include
Means 10 and 82 with median 3; ranges 20 and 80; IQR 15.3; bin counts 2, 2, 3, 1 and 4, 4; a bar chart (not a histogram) for programme counts.
Worked example and code
Try the task in the PDF first, then compare your working below. Run the code in your own Python notebook.
Open Lab 6 instructions (PDF)Task 2 · L6 p. 2.
1. One large value
logins = [1, 2, 3, 4, 40]
print("Mean:", mean(logins), "Median:", median(logins))
logins_big = [1, 2, 3, 4, 400] # a NEW list; the original is unchanged
print("Mean:", mean(logins_big), "Median:", median(logins_big))
Output: Mean: 10 Median: 3 then Mean: 82 Median: 3.
Prediction check: the sum rises from 50 to 410, so the mean becomes 410/5 = 82; the third sorted value is still 3, so the median does not move. The mean moves more because it uses every value's size; the median uses only the middle position. A large observation is not automatically an error: one student may genuinely log in 400 times. Check the source before treating it as invalid (lesson 4.10).
2. Equal means, different spread
A = [50, 55, 60, 65, 70]
B = [20, 40, 60, 80, 100]
print("A:", mean(A), max(A) - min(A))
print("B:", mean(B), max(B) - min(B))
Output: A: 60 20 and B: 60 80. Both means are 60 points, but B's range is 80 points versus A's 20, so B is far more spread out. The mean alone cannot distinguish a tightly clustered class from a widely spread one.
IQR for 1,200 students: IQR = Q3 − Q1 = 73.6 − 58.3 = 15.3 points. The middle half of the students (between the 25th and 75th percentiles) have entry scores within a 15.3-point band from 58.3 to 73.6. These are student entry scores, not registration final grades. IQR uses the two quartile boundaries; the range uses the extremes and is far more sensitive to one unusual value.
3. Build a histogram
Count by hand first: [40,50): 42, 47 → 2; [50,60): 53, 58 → 2; [60,70): 61, 64, 65 → 3; [70,80]: 78 → 1. Total 8.
grades = [42, 47, 53, 58, 61, 64, 65, 78]
edges = [40, 50, 60, 70, 80]
print("Bin counts:", np.histogram(grades, bins=edges)[0])
plt.hist(grades, bins=edges, edgecolor="black")
plt.xlabel("Final grade in points")
plt.ylabel("Number of registrations")
plt.show()
edges2 = [40, 60, 80]
print("Bin counts:", np.histogram(grades, bins=edges2)[0])
plt.hist(grades, bins=edges2, edgecolor="black")
plt.xlabel("Final grade in points")
plt.ylabel("Number of registrations")
plt.show()
Output: [2 2 3 1] and [4 4]. The x-axis counts final grades in points grouped into intervals; the y-axis counts registrations in each interval. With 10-point bins the most populated interval is 60 to below 70 (3 registrations). With 20-point bins the two halves look equal (4 and 4) and the peak disappears: the bins changed the picture, not the grades.
Choose a plot. Programme is a categorical variable, so programme counts need a bar chart with separate bars (CS = 4, Economics = 2), not a histogram. Histogram bins touch because they are adjacent intervals on one continuous number line; categories have nothing between them, so bar-chart bars keep gaps (lessons 8.4, 8.6).
Saved only in this browser. This note doesn’t fill in the downloaded notebook; “reviewed” is a personal checklist, not a grade.