[Math] Expected travel time for regularly departing trains

algorithmsprobabilitystochastic-processes

I'm going to ask a very simple practical question, but I believe it has some interesting mathematical properties.

The simple variant is: trains depart every $x$ minutes and take $y$ minutes to arrive at the destination. How long should a rider expect his journey to take (waiting plus travel)?

The more complex variant is: $n$ train lines service the stop. Each of the $i \in \{1, 2, … n\}$ lines has trains departing every $x_{i}$ minutes and takes $y_{i}$ minutes to arrive at the destination. Assume arrival times are uncorrelated and random across lines. If the rider takes the first train on any line, what is the expected journey time?

The final, most complex variant: it may be the case that taking the first train on any line is not optimal. (For example, if one of the train lines takes $y_{j} = 30$ minutes to arrive at the next stop while others take 20 minutes, and the waiting times are such that it doesn't make sense to take the slower train anyway.) Unfortunately I'm at a total loss for how to compute this, practically speaking. Mathematically it's minimizing the expectation over all subsets of $\{1, 2, … n\}$, but I need to actually compute it so any tips would be helpful. This is more of a CS question so perhaps I'll cross-post to another site.

Best Answer

For the simple variant, you have a waiting time uniformly distributed in $[0,x]$, so expectation $\frac{x}{2}$, so total time $\frac{x}{2}+y$

Corrected: For a simple version of the more complex variant, suppose there are two lines with uniformly distributed arrival times, but we do not know anything about how they are correlated. On line 1, trains come every 5 minutes and take 40 minutes. On line 2, trains come every 10 minutes and take 37 minutes. On average $\frac{1}{5}+\frac{1}{10}$ trains arrive every minute, so your average waiting time is $\frac{5}{3}$ minutes. Then the chance you take a train on line 2 is $\frac{1}{4}$, $\frac{1}{2}$ that it comes in $5$ minutes times $\frac{1}{2}$ that (given it comes in $5$ minutes) it gets there first. So the total time is $\frac{5}{3}+\frac{3\cdot40}{4}+\frac{37}{4}=40.91$ min.

For your third question (again assuming the arrival times are evenly distributed but uncorrelated), you can look to the first for the expected time for each train. Once you have been waiting $m$ minutes, the expected time for a given train is $\frac{x-m}{2}+y$. When a train arrives, you know how long it will take. If that is less than the expected time of any other train, take it. Otherwise, wait for that one.

Related Question