# Train waiting time in probability

Let's say a train arrives at a stop every 15 or 45 minutes with equal probability (1/2). What is the expected waiting time of a passenger for the next train if this passenger arrives at the stop at any random time. This means that the passenger has no sense of time nor know when the last train left and could enter the station at any point within the interval of 2 consecutive trains.

I was told 15 minutes was the wrong answer and my machine simulated answer is 18.75 minutes. I just don't know the mathematical approach for this problem and of course the exact true answer. Sincerely hope you guys can help me.

• Please add the [self-study] tag & read its wiki. Then tell us what you understand thus far, what you've tried & where you're stuck. We'll provide hints to help you get unstuck. – gung - Reinstate Monica Dec 24 '15 at 14:49
• If you could simulate the answer correctly, then you already have a mathematical approach to the problem. – whuber Dec 24 '15 at 15:04
• For those who might like to study this further, here is a very fast R simulation. It processes several million people per second. n.trains <- 1e4; n.people <- 100 * n.trains; trains <- cumsum(ifelse(runif(n.trains) < 1/2, 15, 45)); people <- cumsum(rexp(n.people, rate=n.people/max(trains))); i <- c(rep(0, n.trains), rep(1, n.people))[order(c(trains, people))]; j <- length(trains) + 1 - rev(cumsum(rev(1-i))); k <- cumsum(i); waits <- (trains[j] - people[k])[i==1]; c(Mean=mean(waits, na.rm=TRUE), N=sum(!is.na(waits))) – whuber Dec 24 '15 at 15:36
• This is basically a (very transparent) manifestation of length-biased sampling, or the renewal paradox. – Mark L. Stone Dec 24 '15 at 15:48
• @whuber Out of curiosity, is there a reason why passengers renewals are assumed to follow an exponential distribution ? Or is it a normal way of simulating this kind of process? – Matthew Lau Dec 24 '15 at 18:32

Picture in your mind's eye the whole train schedule is already generated; it looks like a line with marks on it, where the marks represent a train arriving. On average, two consecutive marks are fifteen minutes apart half the time, and 45 minutes apart half the time.

Now, imagine a person arrives; this means randomly dropping a point somewhere on the line. What do you expect the distance to be between the person and the next mark? First, think of the relative probability of landing in each gap size of mark, and then deal with each case separately.

Does this help? I can finish answering but I thought it's more available to provide some insight so you could finish it on your own.

• Yours is really an insightful answer and helps me a lot. Thanks a lot! – fbabelle Dec 24 '15 at 15:33
• @fbabelle you're welcome, my pleasure! Remember to mark an answer accepted if you feel like it resolves things for you. – Nir Friedman Dec 24 '15 at 15:36

Your simulator is correct. Since 15 minutes and 45 minutes intervals are equally likely, you end up in a 15 minute interval in 25% of the time and in a 45 minute interval in 75% of the time.

In a 15 minute interval, you have to wait $15 \cdot \frac12 = 7.5$ minutes on average.

In a 45 minute interval, you have to wait $45 \cdot \frac12 = 22.5$ minutes on average.

This gives a expected waiting time of $\frac14 \cdot 7.5 + \frac34 \cdot 22.5 = 18.75$.