Problem Solving — CS & DS

Lecture 28 — Summaries That Don't Mislead

Learning objectives

Case-based lecture: you attempt, we discuss, then we reveal.

Today

The plan

Key definitions

Key definitions

Explain each in one breath; the cases will do the heavy lifting.
Worked example

The Salary Parable: mean vs median under skew

cs-109

Salaries 30k, 32k, 35k, 38k, 200k. Which summary survives, and how would each be (mis)used?

sal = [30, 32, 35, 38, 200]
mean = sum(sal) / len(sal)
sorted_sal = sorted(sal)
median = sorted_sal[len(sorted_sal) // 2]
print(mean, median)

Expected: mean 67k, median 35k - the 32k gap is the skew alarm

Cost: O(n) mean, O(n log n) median by sorting (O(n) selection exists - enrichment).

Worked example

The Percentage Maze: percentages of what?

cs-110

A price rises 20%, then falls 20%. Back to the start? And: churn fell from 10% to 8% - is that '2%' or '20%' better?

price = 100 * 1.20 * 0.80
points = 10 - 8
relative = (10 - 8) / 10
print(price, points, relative)

Expected: price ends at 96 (not 100); churn: -2 points = -20% relative

Cost: O(1); the skill is vocabulary discipline, not arithmetic.

Worked example

The Waiting-Time Twist: averages that hide the experience

cs-111

Waiting times (minutes): 684 customers' experiences compress to: most wait 2, a few wait 60+. Report honestly: which average, and what must accompany it?

waits = [2, 2, 2, 3, 4, 5, 60, 70]
med = sorted(waits)[len(waits) // 2]
mean = sum(waits) / len(waits)
tail = sum(1 for w in waits if w > 30) / len(waits)
print(med, round(mean, 1), tail)

Expected: median 3 min, mean 18.5 min, 25% wait over 30 min

Cost: O(n log n) with the sort; all three summaries from one pass over sorted data.

Case attempt · lecture 28
Case cs-109 · Beginner

The Salary Parable

One billionaire joins a 9-person seminar: the mean salary explodes. Mean vs median, when each is honest, and how to state them.

⏱ 5 minutes — attempt now

Pseudocode, flowchart or Python. State one assumption. Compare with your neighbour at minute 4.

Discussion

cs-109 — discuss

Instructor: the reveal, the reasoning section and common wrong turns are in the instructor distribution for cs-109 — not embedded in this deck.

Case attempt · lecture 28
Case cs-110 · Foundational

The Percentage Maze

'Sales up 50% then down 40%' — why that's a net gain, not a loss. Percentage bases; then reconstruct a table from percentage claims.

⏱ 5 minutes — attempt now

Pseudocode, flowchart or Python. State one assumption. Compare with your neighbour at minute 4.

Discussion

cs-110 — discuss

Instructor: the reveal, the reasoning section and common wrong turns are in the instructor distribution for cs-110 — not embedded in this deck.

Case attempt · lecture 28
Case cs-111 · Intermediate

The Waiting-Time Twist

Buses every 10 minutes, yet average wait is 15. Why your sample differs from the schedule's average (length-biased sampling), and the fix.

⏱ 5 minutes — attempt now

Pseudocode, flowchart or Python. State one assumption. Compare with your neighbour at minute 4.

Discussion

cs-111 — discuss

Instructor: the reveal, the reasoning section and common wrong turns are in the instructor distribution for cs-111 — not embedded in this deck.

Case attempt · lecture 28
Case cs-112 · Advanced

The Dashboard Defence

A dashboard shows 'average response time 2s'. Find three honest-but-misleading framings and redesign the summary. Communication as a design problem.

⏱ 5 minutes — attempt now

Pseudocode, flowchart or Python. State one assumption. Compare with your neighbour at minute 4.

Discussion

cs-112 — discuss

Instructor: the reveal, the reasoning section and common wrong turns are in the instructor distribution for cs-112 — not embedded in this deck.

Case attempt · lecture 28
Case cs-135 · Expert

The Split That Leaks

A team builds a study-hours → pass/fail predictor for 40 students and reports: *"test accuracy computed on 20 held-out rows."* Their pipeline:

⏱ 5 minutes — attempt now

Pseudocode, flowchart or Python. State one assumption. Compare with your neighbour at minute 4.

Discussion

cs-135 — discuss

Instructor: the reveal, the reasoning section and common wrong turns are in the instructor distribution for cs-135 — not embedded in this deck.

Check yourself

Common misconceptions

Summary

Summary & exit question

Exit question (choose one, 60 seconds)

  1. When must the median replace the mean?
  2. What is the percentage maze's core error?
  3. State the inspection paradox in one line.
Expected answers (instructor): under skew or outliers — any time a tail can dominate comparing percentages with different bases sampled experiences oversample long waits/stays — the sampling is length-biased
→ / space: next · ←: back · Home/End: jump · Ctrl+P → PDF