2009年9月12日 星期六

等巴士之謎

假設某路線的巴士每 20 分鐘一班。如果乘客到達車站的時間是隨機的,而巴士又永遠準時到站的話,那麼乘客的平均候車時間是 10 分鐘(當然,最短的候車時間是 0 分鐘,最長則是 20 分鐘)。如果班次不準確但車子的數目不變的話(例如有些班次早到數分鐘,有些遲到數分鐘),那麼對乘客的平均候車時間將有何影響?

看下去之前,不妨停下來先想想。

由於車子的數目不變,那麼有些班次早到而有些遲到的話,表面上平均候車時間似乎不變(車子遲來的話,有些人久等了,但有些卻因而趕上該車子,而車子早來的情況也類似),其實不然。

考慮一下這個頗為極端的情況:單數的班次(第 1 班、第 3 班、……)總是遲到 10 分鐘,而雙數的班次則總是早到 10 分鐘。那麼,20 分鐘一班的巴士會變成每 40 分鐘一次過來兩班,但對乘客來說這跟每 40 分鐘一班沒有分別 -- 平均候車時間變成了 20 分鐘!

再考慮另一個情況:單數的班次總是遲到 3 分鐘,而雙數的班次則總是早到 3 分鐘。那麼從某班單數的班次開出到下一個單數班次到站的 40 分鐘可視為一個循環,如果我們假設這 40 分鐘期間每分鐘有一名乘客到達車站的話,那麼他們的候車時間分別為 14、13、…、1、0、25、24、…、1、0 分鐘,不難發現平均候車時間超過 10 分鐘(可以不經計算而看出此事嗎?)。

一般來說,如果巴士並非全部準時到達的話,那麼平均候車時間便會超過 10 分鐘。因為時間是連續的,要嚴謹證明這事有點麻煩,故這裡從略。不過懂得積分(integration)的讀者可以一試,事實上以上結果是排序不等式(rearrangement inequality)的一個「連續版(continuous version)」呢。

3 則留言:

Pop 提到...

We can discuss this topic by using simple statistics tech .

Assume:
0)班次不準確但車子的數目不變
1) 乘客到達車站的時間是隨機的
Uniform distribution between the bus service time, that is no rush hour. (discrete or continuous doesn't matter)
2) All waiting passengers can take on the first arrival bus.
3) No passenger come to bus stop after the last bus departure.
4) For easier discussion, assume the last bus is on time.

Let have some examples to get some ideas.
i)
假設某路線的巴士每 20 分鐘一班。如果乘客到達車站的時間是隨機的,而巴士又永遠準時到站的話,那麼乘客的平均候車時間是 10 分鐘

Draw a diagram, Y-axix is waiting time and X-axis is the time line.
We will have continues iso. triangles with height 20 and base 20.
Within each class, every 20 mins, the average is waiting time is 10 mins. So the overall mean waiting time is the average of all classes' mean. that is 10 mins.

ii)
單數的班次總是遲到 3 分鐘,而雙數的班次則總是早到 3 分鐘。那麼從某班單數的班次開出到下一個單數班次到站的 40 分鐘可視為一個循環
Draw a diagram similar as i)
We will have consecutive iso. triangles with height 17 and 23.
so the classes' average waiting time is 17/2 and 23/2.
To calculate the overall mean waiting time, we need to use weighted mean as each classes width is diff.
For example, 40 分鐘可視為一個循環

the overall mean = (17/40)*(17/2)+(23/40)*(23/2)
=(17^2+23^2) / 2*(17+23)

Let Xi be the time in-between 2 bus arrived.
So the overall mean of waiting time
= Sum (Xi^2) / 2*Sum(Xi)

By using s^2=Sum(Xi-u)^2, u = mean of Xi, s = s.d. of Xi
we have s^2 = Sum Xi^2 -2u*Sum(Xi)+Sum(u^2)
s^2= Sum(Xi^2)-n(u^2)

Thus, overall mean waiting time
= [s^2 + n(u^2)] / 2*[n(u)]
= u/2 + s^2/2nu

As s^2(varanice) is positive, we draw the required conclusion.
一般來說,如果巴士並非全部準時到達的話,那麼平均候車時間便會超過 10 分鐘

if 巴士又永遠準時到站, i.e s^2 =0, and the 巴士又永遠準時到站 = u /2

Pop 提到...

Correction:
By using s^2=(1/n)[Sum(Xi-u)^2], u = mean of Xi, s = s.d. of Xi
we have n*s^2 = Sum Xi^2 -2u*Sum(Xi)+Sum(u^2)
n*s^2= Sum(Xi^2)-n(u^2)

Thus, overall mean waiting time
= [n*s^2 + n(u^2)] / 2*[n(u)]
= u/2 + s^2/2u

Kahoo 提到...

Thanks, Pop. Your idea of using statistical techniques is nice.