2 trams are coming every 5 and 10 minutes. On average, how long do I have to wait for any tram to come?

371 Views Asked by At

I want to follow the approach from Christian Blatter here

3 trams are coming every 10, 15 and 15 minutes. On average, how long do I have to wait for any tram to come?

using "the assumption that the trams arrive on time with unknown but equidistributed phases. In the following I shall treat model". However, my theoretical result do not match my simulation result.

A random point $P=(X,Y)$ is chosen in the block $$B:=\{(x,y)\>|\>0\leq x\leq5,\ 0\leq y\leq 10,\}\ .$$ The waiting time $T$ is then given by $T=\min\{X,Y\}$.

The points $P$ with waiting time between $t$ and $t+dt$ is a panel of thickness $dt$ and having a distance $t$ from the planes $x=0$ and $y=0$. (Here the union of pairwise buses is one because there are only two buses.) The area of the panel is $(10-t)(5-t)$.

Therefore, the pdf $f_T$ of the waiting time is given by $$f_T(t)={1 \over 5 \cdot 10}(5-t) \cdot (10-t) \qquad(0\leq t\leq5)\ .$$ $$f_T(t)={1 \over 50}(50-15t+t^2) \qquad(0\leq t\leq5)\ .$$

From this we obtain the expected waiting time as $$E(T)=\int_0^{5} t \cdot f_T(t) dt= \int_0^{5} \frac{1}{50}[50t-15t^2+t^3] = \frac{1}{50}[50/2t^2-15/3t^3+1/4t^4)]^{5}_0 = 3.125.$$

However, from my simulation I get around 2.09, I guess that is 25/12:

I did a R simulation with the assumptions that buses arrive promptly every 5 and 10 minutes, respectively. However, the interval time among buses is fixed with uniformly distributed starting times. I simulate buses between [0,10000] minutes and the guy arriving at the bus stop at time t in [50,9950] and check the minimum time to next bus (which arrives first out of 2).

   upperbound <- 10000
   waitVector <- vector()
   nbRuns <- 10000
   for(count1 in 1:nbRuns) {
     seq1 <- 10*runif(1) + seq(from=0,to=upperbound,by=10)
     seq2 <- 5*runif(1) + seq(from=0,to=upperbound,by=5) # uniformly distributed, but fixed distance among both buses
     seq3 <- sort(c(seq1,seq2))
     arrivalTime <- runif(n=1,min=50,max=(upperbound-50))
     minSeq <- seq3 - arrivalTime
     minSeq <- minSeq[minSeq > 0] # cant catch bus who left before I arrived
     minTime <- min(minSeq)
     waitVector <- c(waitVector,minTime)
}
minAvgWaitTime <- mean(waitVector)
print(range(waitVector))
print(paste("Minimum avg wait time base on ",nbRuns," simulations is: ",minAvgWaitTime,sep=""))
2

There are 2 best solutions below

10
On BEST ANSWER

Your transfer of the solution from $3D$ to $2D$ is wrong. What was a plane is now a line; what was a panel is now a strip. There are two strips of width $\mathrm dt$, with lengths $10-t$ and $5-t$, so the probability distribution function is

$$ f_T(t)=\frac{15-2t}{50} $$

and the expected waiting time is

$$ E(T)=\int_0^5tF_T(t)\,\mathrm dt=\frac{25}{12}\;. $$

0
On

Personally, I find it much easier to think in CDF terms. In this example, the cumulative probability of waiting for a tram for up to $t$ corresponds to the area of the shaded region in the chart below.

enter image description here

In other words, $F_T(t) = \frac{1}{50} (5t + 10t - t^2)$, and $f_T(t) = \frac{1}{50} (15 - 2t)$. We thus avoid thinking in $dt$ terms.

This could have been a comment to @joriki answer, but I need to include the chart.