我碰到一个面试问题:
每隔10分钟就有一列红色火车驶来。每隔15分钟就有一列蓝色火车驶来。两者都是从随机时间开始的,因此您没有任何时间表。如果您在随机时间到达车站并乘坐第一班来往的火车,那么预计的等待时间是多少?
我碰到一个面试问题:
每隔10分钟就有一列红色火车驶来。每隔15分钟就有一列蓝色火车驶来。两者都是从随机时间开始的,因此您没有任何时间表。如果您在随机时间到达车站并乘坐第一班来往的火车,那么预计的等待时间是多少?
Answers:
解决问题的一种方法是从生存功能开始。为了必须等待至少分钟,您必须为红色和蓝色火车都至少等待t分钟。因此,总体生存功能只是各个生存功能的乘积:
其中,对于,是,你必须等待至少概率牛逼分钟下一班车。这考虑到了对OP的澄清,该注释中的正确假设是,每列火车都在固定的时间表上,而不依赖于其他时间表以及与旅客的到达时间无关,并且两列火车的相位是均匀分布的,
然后得到pdf
并以通常的方式获得期望值:
,
算到分钟
答案是 获取括号内的部分: ∫ý<XŶdŶ=ý2/2| X 0 =X2/2∫ý>XXdŶ=Xÿ| 15 X =15X-X2 所以,部分是: (。)=(∫ý<Xýdÿ+
这是要模拟的MATLAB代码:
nsim = 10000000;
red= rand(nsim,1)*10;
blue= rand(nsim,1)*15;
nextbus = min([red,blue],[],2);
mean(nextbus)
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 minutes is for , which when integrated gives minutes
Alternatively, assuming each train is part of a Poisson process, the joint rate is trains a minute, making the expected waiting time minutes
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:
Suppose that red and blue trains arrive on time according to schedule, with the red schedule beginning minutes after the blue schedule, for some . For definiteness suppose the first blue train arrives at time .
Assume for now that lies between and minutes. Between and minutes we'll see the following trains and interarrival times: blue train, , red train, , red train, , blue train, , red train, , blue train. Then the schedule repeats, starting with that last blue train.
If denotes the waiting time for a passenger arriving at the station at time , then the plot of versus is piecewise linear, with each line segment decaying to zero with slope . So the average wait time is the area from to of an array of triangles, divided by . This gives
If is not constant, but instead a uniformly distributed random variable, we obtain an average average waiting time of
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.