Headways and waiting time / 发车间隔与候车时间 / 運行間隔と待ち時間 Recorded: 2026-11-02 Run calculations (standard library only) python3 headway-waiting-lab.py > rerun.json Recorded: macOS 27.0.1, arm64, CPython 3.12.14. The default command reads no external files and writes its JSON report to stdout. The shell redirect writes rerun.json. No network or real transit API is used. Optional plot Install Matplotlib in your chosen Python environment, then run: python3 headway-waiting-lab.py --plot headway-waiting-comparison.svg > rerun.json The optional branch writes both the named SVG and a PNG with the same basename. Recorded plotting version: Matplotlib 3.11.2 (temporary tooling, no blog dependency). The figure is an original illustration of the synthetic model, not observed data. SVG date metadata and hash salt are fixed for byte reproducibility in this version. Model The gaps in minutes form a repeating cycle, including the final gap back to the next cycle's first departure. Arrival phase is continuous uniform in the cycle and independent of departures. Every next bus can be boarded. Exact-departure arrival boards immediately (wait 0); isolated endpoints have zero probability under the continuous uniform model. No capacity, transfer, walking, varying demand, or first/last service cutoff. Methods and recorded checks Exact fractions: mean wait = sum(h*h)/(2*sum(h)). Exact population-variance identity: mean/2 + variance/(2*mean). Population variance divides by interval count n, not sample divisor n-1. Separately look up the next departure at every one-second cell's midpoint. Integer-minute departures and checked thresholds are on cell boundaries, so midpoint integration and the reported tail checks are exact here. No random samples, random seed, Monte Carlo error, or measured failure rates. Seven reported gap lists: 10,10 -> mean wait 5; 90th percentile 9; P(wait>5)=1/2. 5,15 -> mean wait 25/4; 90th percentile 13; P(wait>5)=1/2. 1,19 -> mean wait 181/20=9.05; 90th percentile 17; P(wait>5)=7/10. 1,1,28 -> mean wait 131/10=13.1; 90th percentile 25. 0,20 -> mean wait 10; 90th percentile 18. 10 -> mean wait 5. 19,1 -> same uniform-time waiting distribution as 1,19. Scaling 1,19 to 2,38 doubles the mean wait. Seven invalid inputs rejected: empty list, all zero, negative gap, bool, float, string and None under this integer-minute input contract. Eight exact arrival-time queries include departure instants, fractional times, negative phase and cycle wraparound. Planned arrivals at 9 and 19 in the 10,10 schedule both wait 1 minute; this changes the arrival model and is not the uniform-time calculation. Figure Upper panel: gaps 10+10. Lower panel: gaps 1+19. Shaded triangle area divided by the 20-minute cycle is the mean wait. Open peaks show the right-limit wait just after departure; filled dots at departures show immediate boarding. Dashed lines mark the two means. English axis labels are shared by the complete Chinese and Japanese articles. Primary educational sources checked MIT OCW Public Transportation Systems, Spring 2017, Lecture 9: https://ocw.mit.edu/courses/1-258j-public-transportation-systems-spring-2017/resources/lecture-9-performance-models/ Official transcript: https://ocw.mit.edu/courses/1-258j-public-transportation-systems-spring-2017/8766f0b7eb9154c7a81acb57ebf3ffab_Tsn0xSQjo14.vtt Lecture 20: https://ocw.mit.edu/courses/1-258j-public-transportation-systems-spring-2017/resources/lecture-20-service-reliability/ Official transcript: https://ocw.mit.edu/courses/1-258j-public-transportation-systems-spring-2017/5803b92a19f357f0add0ebf14ab7ef47_I2K5WnG_TLs.vtt Python Fraction: https://docs.python.org/3.12/library/fractions.html The arithmetic, fixtures, code and plot are original teaching material. No MIT transcript text, lecture images or actual transport records are bundled. ZIP contents: script, recorded report, SVG, this README.