Expected Wait for a Bus That Runs Late Half the Time
Company: Optiver
Role: Data Scientist
Category: Machine Learning
Difficulty: medium
Interview Round: Technical Screen
Buses on a certain route are scheduled to arrive at your stop every $x$ minutes. Independently for each bus, the bus arrives exactly on schedule with probability $1/2$, and exactly $x/2$ minutes late with probability $1/2$ (a bus is never early). You walk up to the stop at a uniformly random moment, independent of the schedule and of the delays, and you board the first bus that arrives after you get there.
What is your expected waiting time, expressed in terms of $x$?
```hint Model one schedule slot
Place your arrival uniformly inside the interval between two consecutive *scheduled* times. Whether the bus scheduled at the start of that slot is still ahead of you depends on its delay — a late bus scheduled *before* you arrived may still be the one you catch. Condition on the delays of the two surrounding buses.
```
```hint A renewal shortcut
The delays never reorder buses (a delay of $x/2$ is smaller than the $x$ headway), so the timeline is a stationary sequence of gaps $G$ between consecutive bus arrivals. A uniformly random arriver is more likely to land in a long gap, so the expected wait is $\frac{E[G^2]}{2\,E[G]}$, not $E[G]/2$. Work out the distribution of the gap $G$ first.
```
### Constraints & Assumptions
- The scheduled headway is exactly $x$ minutes, and the schedule extends indefinitely (analyze the steady state, ignoring boundary effects).
- Each bus is late by exactly $x/2$ minutes with probability $1/2$ and on time otherwise; delays are independent across buses; buses are never early.
- Because the maximum delay $x/2$ is smaller than the headway $x$, buses never overtake one another.
- Your arrival time is uniform over a long horizon and independent of all delays; the waiting time ends when the next bus arrives at the stop.
### Clarifying Questions to Ask
- Is the delay exactly $x/2$ minutes, or up to $x/2$ (e.g., uniformly distributed)?
- Are the delays of different buses independent of each other?
- Can a bus ever be early, and can buses overtake each other?
- Do I board the first bus that physically arrives, regardless of which scheduled run it corresponds to?
- Should I treat my arrival as uniformly random in steady state, with no boundary effects at the start of service?
### What a Strong Answer Covers
- A precise model of the arrival process — scheduled times plus i.i.d. delays — including a justification that the bus order is preserved.
- Correct handling of the subtle case where the bus scheduled just before your arrival is late and has not yet departed, so it is the bus you catch.
- A valid averaging argument: either direct conditioning on the neighboring buses' delays with a uniform arrival time, or a length-biased (inspection-paradox) argument over the gap distribution, with awareness of why a random arriver over-samples long gaps.
- A closed-form answer in terms of $x$, sanity-checked against the deterministic no-delay baseline of $x/2$, with an explanation of the direction of the change.
### Follow-up Questions
- Recompute the expected wait if each bus's delay is instead uniform on $[0, x/2]$.
- Generalize: if a bus is late by $d$ minutes with probability $p$ (and on time otherwise, with $d < x$), what is the expected wait as a function of $x$, $p$, and $d$?
- What does your gap-based formula say about why irregular headways always increase a random rider's expected wait, even when the mean headway stays the same?
- How would the answer change qualitatively if buses instead arrived as a Poisson process with mean headway $x$?