每10和15分钟一班的两辆公交车中的第一辆公交车的等待时间的期望值


19

我碰到一个面试问题:

每隔10分钟就有一列红色火车驶来。每隔15分钟就有一列蓝色火车驶来。两者都是从随机时间开始的,因此您没有任何时间表。如果您在随机时间到达车站并乘坐第一班来往的火车,那么预计的等待时间是多少?


3
火车是按时到达但相位未知分布是否均匀,还是遵循泊松过程,即平均10分钟和15分钟。
— Tilefish Poele

1
前者,而不是泊松。
— 张胜杰

7
@Tilefish提出了每个人都应注意的重要评论。 没有确切的答案。 您必须假设“从随机时间开始”可能意味着什么。(这是说它们同时开始还是在不同的未知时间开始?这有什么理由将“未知”视为具有确定的已知分布的随机变量?)作为其相位差的函数(仅以5分钟为模),答案可以变化从15/4到25/6。的相位差的均匀分布将产生35/9。
— ub

@whuber每个人似乎都将OP的评论解释为好像两辆公共汽车在两个不同的随机时间发车。他们会在相同的随机时间开始似乎是不寻常的事情
— Aksakal

1
@Aksakal。并非所有人:我没有,并且在这个线程中至少有一个答案没有-这就是为什么我们看到不同的数字答案。而且,几乎没有人承认,为了获得答案,他们必须对问题作这样的解释。
— ub

Answers:


15

解决问题的一种方法是从生存功能开始。为了必须等待至少分钟,您必须为红色和蓝色火车都至少等待t分钟。因此,总体生存功能只是各个生存功能的乘积:tt

S(t)=(1−t10)(1−t15)

其中,对于,是,你必须等待至少概率牛逼分钟下一班车。这考虑到了对OP的澄清,该注释中的正确假设是,每列火车都在固定的时间表上,而不依赖于其他时间表以及与旅客的到达时间无关,并且两列火车的相位是均匀分布的,0≤t≤10t

然后得到pdf

p(t)=(1−S(t))′=110(1−t15)+115(1−t10)

并以通常的方式获得期望值:

,E[t]=∫010tp(t)dt=∫010t10(1−t15)+t15(1−t10)dt=∫010(t6−t275)dt

算到分钟359


戴夫,您能解释一下p(t)=(1- s(t))'吗?
— Chef1075

我可以解释一下,对于您来说S(t)= 1-F(t),p(t)只是f(t)= F(t)'。
— 深北

4
生存功能的想法很棒。但是,当您可以直接集成生存函数以获得期望时,为什么要导出PDF?实际上,这个答案的三分之二只是用一个特定的例子证明了微积分的基本定理。什么证明使用该产品获得是合理的?这背后隐藏着一个假设。S
— ub

2
@whuber我喜欢这种方式,获得由生存功能的PDF,因为它正确地处理的情况下随机变量的域不从0开始
— 戴夫

2
(1)您的域名是肯定的。(2)该公式易于推广。。
— ub

9

答案是 获取括号内的部分: ∫ý<XŶdŶ=ý2/2| X 0 =X2/2∫ý>XXdŶ=Xÿ| 15 X =15X-X2 所以,部分是: (。)=(∫ý<Xýdÿ+

E[t]=∫x∫ymin(x,y)110115dxdy=∫x(∫y<xydy+∫y>xxdy)110115dx
∫y<xydy=y2/2|0x=x2/2
∫y>xxdy=xy|x15=15x−x2
最后,ë[吨]= ∫ X(15X-X2/2) 1
(.)=(∫y<xydy+∫y>xxdy)=15x−x2/2
E[t]=∫x(15x−x2/2)110115dx=(15x2/2−x3/6)|010110115=(1500/2−1000/6)110115=5−10/9≈3.89

这是要模拟的MATLAB代码:

nsim = 10000000;
red= rand(nsim,1)*10;
blue= rand(nsim,1)*15;
nextbus = min([red,blue],[],2);
mean(nextbus)

1
您对火车的初始起点做出了错误的假设。即使用您的逻辑,每2个小时会有几列红色和蓝色的火车出现?2小时内总共有几列火车?等
— Tilefish Poele

1
火车不能在0分钟和60分钟到达吗?
— Tilefish Poele

1
我想说的是如果它们同时开始怎么办?如果它们都在分钟0开始,该怎么办?您有多少趟火车到达?
— Tilefish Poele

1
模拟不能完全模拟问题陈述。特别是,它不会模拟您在公交车站出现的“随机时间” 。因此,它体现了对该问题的一些未阐明的假设。
— ub

2
@whuber模拟了相对于我到达车站的公交车相位
— Aksakal

4

Assuming each train is on a fixed timetable independent of the other and of the traveller's arrival time, the probability neither train arrives in the first x minutes is 10−x10×15−x15 for 0≤x≤10, which when integrated gives 359≈3.889 minutes

Alternatively, assuming each train is part of a Poisson process, the joint rate is 115+110=16 trains a minute, making the expected waiting time 6 minutes


3
@Dave it's fine if the support is nonnegative real numbers.
— Neil G

3
@dave He's missing some justifications, but it's the right solution as long as you assume that the trains arrive is uniformly distributed (i.e., a fixed schedule with known constant inter-train times, but unknown offset). It works with any number of trains. This is the because the expected value of a nonnegative random variable is the integral of its survival function.
— Neil G

1
@Dave with one train on a fixed 10 minute timetable independent of the traveller's arrival, you integrate 10−x10 over 0≤x≤10 to get an expected wait of 5 minutes, while with a Poisson process with rate λ=110 you integrate e−λx over 0≤x<∞ to get an expected wait of 1λ=10 minutes
— 亨利

1
@NeilG TIL,“非负随机变量的期望值是生存函数的整数”,有点-棘手之处在于随机变量的域需要从 0,并且如果它本质上不是从零开始的(例如,对于另一个问题,例如到达间隔时间在5分钟到10分钟之间均匀分布),则在集成生存函数时实际上必须使用下界0 。(从零开始是必需的,以便在进行部分积分后取消边界项)
— 戴夫

3
+1 At this moment, this is the unique answer that is explicit about its assumptions. All the others make some critical assumptions without acknowledging them.
— whuber

2

I am probably wrong but assuming that each train's starting-time follows a uniform distribution, I would say that when arriving at the station at a random time the expected waiting time for:

  1. the Red train is E[R]=5 mins
  2. the Blue train is E[B]=7.5 mins
  3. the train that comes the first is E[min(R,B)]=1510(E[B]−E[R])=154=3.75 mins


As pointed out in comments, I understood "Both of them start from a random time" as "the two trains start at the same random time". Which is a very limiting assumption.


1
Thanks! Your got the correct answer. But 3. is still not obvious for me. Could you explain a bit more?
— Shengjie Zhang

1
This is not the right answer
— Aksakal

1
I think the approach is fine, but your third step doesn't make sense.
— Neil G

2
This answer assumes that at some point, the red and blue trains arrive simultaneously: that is, they are in phase. Other answers make a different assumption about the phase.
— whuber

2

Suppose that red and blue trains arrive on time according to schedule, with the red schedule beginning Δ minutes after the blue schedule, for some 0≤Δ<10. For definiteness suppose the first blue train arrives at time t=0.

Assume for now that Δ lies between 0 and 5 minutes. Between t=0 and t=30 minutes we'll see the following trains and interarrival times: blue train, Δ, red train, 10, red train, 5−Δ, blue train, Δ+5, red train, 10−Δ, blue train. Then the schedule repeats, starting with that last blue train.

If WΔ(t) denotes the waiting time for a passenger arriving at the station at time t, then the plot of WΔ(t) versus t is piecewise linear, with each line segment decaying to zero with slope −1. So the average wait time is the area from 0 to 30 of an array of triangles, divided by 30. This gives

W¯Δ:=130(12[Δ2+102+(5−Δ)2+(Δ+5)2+(10−Δ)2])=130(2Δ2−10Δ+125).
Notice that in the above development there is a red train arriving Δ+5 minutes after a blue train. Since the schedule repeats every 30 minutes, conclude W¯Δ=W¯Δ+5, and it suffices to consider 0≤Δ<5.

If Δ is not constant, but instead a uniformly distributed random variable, we obtain an average average waiting time of

15∫Δ=05130(2Δ2−10Δ+125)dΔ=359.

2

This is a Poisson process. The red train arrives according to a Poisson distribution wIth rate parameter 6/hour.
The blue train also arrives according to a Poisson distribution with rate 4/hour. Red train arrivals and blue train arrivals are independent. Total number of train arrivals Is also Poisson with rate 10/hour. Since the sum of The time between train arrivals is exponential with mean 6 minutes. Since the exponential mean is the reciprocal of the Poisson rate parameter. Since the exponential distribution is memoryless, your expected wait time is 6 minutes.


The Poisson is an assumption that was not specified by the OP. But some assumption like this is necessary. The logic is impeccable. +1 I like this solution.
— Michael R. Chernick

1
OP said specifically in comments that the process is not Poisson
— Aksakal
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.