Chapter 7 — Missing trip counts
Lesson map
Lesson 07 published. Map, example, EX025.
flowchart TD
N0["Learning outcomes"]
N1["7.1 The check"]
N2["Lab — Scheduled trips without passenger count record"]
N3["7.2 Results"]
N4["7.3 Finding the cause"]
N5["7.4 Reporting"]
N0 --> N1 --> N2 --> N3 --> N4 --> N5
N5 --> EX["Worked example"]
EX --> Q["Exercise EX025"]
Logical drawing
flowchart LR
N0["Learning outcomes"]
N1["7.1 The check"]
N2["Lab — Scheduled trips without passenger count record"]
N3["7.2 Results"]
N4["7.3 Finding the cause"]
N5["7.4 Reporting"]
N0 --> N1 --> N2 --> N3 --> N4 --> N5 --> Q["EX025"]
[Learning outcomes]
|
v
[7.1 The check]
|
v
[Lab — Scheduled trips without passenger count record]
|
v
[7.2 Results]
|
v
[7.3 Finding the cause]
|
v
[7.4 Reporting]
|
v
[Worked example] --> [Exercise EX025]
Learning outcomes
You will (1) compare counts with the timetable; (2) find routes with missing counts; (3) report the problem to the right person.
7.1 The check
Marta writes a check that compares the timetable with the count records. Every scheduled trip should have one count record. Trips without a record are listed by route. She explains that this completeness check matters most for funding, because the transport authority pays for funded routes based on reported passengers, and a missing count records zero passengers for that trip. She runs the check on one month of synthetic data covering three routes. She saves the check in the shared folder with her other scripts.
Lab — Scheduled trips without passenger count records, by route
"""Find scheduled bus trips with no passenger count record, by route (stdlib only)."""
import random
random.seed(12)
miss = {"Route 1": 0.01, "Route 4": 0.02, "Route 7": 0.09}
tot = 0
for r, p in miss.items():
m = sum(random.random() < p for _ in range(1200))
tot += m
print(f"{r}: 1200 trips scheduled, {m} without counts ({100*m/1200:.1f}%)")
print(f"all routes: {tot} of 3600 missing ({100*tot/3600:.1f}%)")
Run with python3 lab_trips.py. Verified output:
Route 1: 1200 trips scheduled, 12 without counts (1.0%)
Route 4: 1200 trips scheduled, 10 without counts (0.8%)
Route 7: 1200 trips scheduled, 122 without counts (10.2%)
all routes: 144 of 3600 missing (4.0%)
7.2 Results
The lab checks twelve hundred scheduled trips on each of three routes. Route 1 has 12 trips without counts, 1.0 percent. Route 4 has 10, 0.8 percent. Route 7 has 122, 10.2 percent. Across all three routes, 144 of 3,600 trips are missing, 4.0 percent. Marta notes that the overall figure hides the real problem: most missing counts are on Route 7, which is far worse than the other two routes. Marta writes the results in a small table with one row per route, so that the difference between Route 7 and the other routes is obvious to anyone who reads it, including managers who are not used to data.
7.3 Finding the cause
Marta shares the result with Mr. Hughes. He checks which buses run Route 7 and finds that two older buses on that route have sensors that often fail to save data. Route 7 is the hospital route, which the authority part-funds. Missing counts there could reduce funding for a route many patients and staff depend on. Mr. Hughes asks maintenance to repair the sensors and to move newer buses onto Route 7 meanwhile. Marta records the cause and the actions in her workbook, and plans to check Route 7 again after the repairs.
7.4 Reporting
Marta writes a short report: what she checked, the results by route, the likely cause, the action taken and a plan to rerun the check next month. She sends it to Mr. Hughes, who forwards it to the operations manager. Mr. Osei notes that reporting by route rather than as one overall figure made the problem visible, and that technicians should always look for where problems concentrate rather than only at totals. The operations manager thanks Marta and asks for the same check every month.
Worked example
Marta compares timetable and counts, finds 144 of 3,600 trips missing (4.0 percent) with Route 7 at 10.2 percent, sees older buses' sensors as the cause and reports by route with a rerun plan.
Synthetic case. Trips are synthetic; outputs come from lab_trips.py.
Errors and limits
Overall percentages hide routes where problems concentrate.
Exercises
- EX025 — Route 7 share. What share of Route 7 trips lacked counts? Rubric: 3 = 10.2%;; 2 = partly correct;; 1 = wrong;; 0 = none.
- EX026 — Overall missing. How many trips were missing across all routes? Rubric: 3 = 144 of 3,600;; 2 = partly correct;; 1 = wrong;; 0 = none.
- EX027 — Route 7 cause. What caused missing Route 7 counts? Rubric: 3 = sensors on two older buses;; 2 = partly correct;; 1 = vague;; 0 = none.
- EX028 — Interim action. What was done while sensors were repaired? Rubric: 3 = newer buses moved onto Route 7;; 2 = partly correct;; 1 = vague;; 0 = none.
Continue studying — lesson 07 (chapter 07 of 18)
← Chapter 06 · Course chapter index · Chapter 08 →
Continue to the next authored lesson.