上次我跨下海口, 聲稱今次的成功率將是90%, 比first attempt的83.33%還高出大概6%. 哈哈, 我錯了, second attempt的成功率在某些情況下有更良好的表現, 但在某種情況下有更差的表現. 而且second attempt的成功率(即expectation)不是隨著人口的增加而一味增多, 也不是隨著人口減少而一味增多. 看看:
expectation=81% when population=4
expectation=84% when population=6
expectation=67% when population=12
expectation=72% when population=52
無論如何, 今次的結果能使我更能了解一些辦法, 是跨進"正解"(成功率=??%)的一大步.
上次我們將所有人分成兩批: 1/3人 是 "犧牲者", 2/3人是 "必然生存者". 我希望今次可以將"犧牲者"減至1人. 有可能嗎? 有! 可惜"必然生存者"的人數不是(總人數減1), 是少於這個數目. 今次出現了一批人, 又不是"必然生存", 又不是肯定死亡, 又不是主要用來提供資料, 且稱這批人為"或者死亡人". 這批人死不死視情況而定.
究竟怎樣做?
let n(population) be even number, 黑帽叫B, 白帽叫W, 由尾至前排起.
e.g. BWBWB
WWWBBBB (即B->W->B->W->B->W->W->W->B->B->B->B)
方法:
排最尾的人, (只一名, 稱犧牲者): 如果前面的黑帽總數<白帽, 叫:"黑帽", 反之亦然. (注意前面人數必然是odd number.) 如果黑帽數=0, 也算是黑帽數<白帽數.
除犧牲者外所有人:
case1) 犧牲者叫"黑帽時". let X=(n-2)/2, 每當後面有人叫"黑帽"時, X:=X-1. 輪到自己叫的時候, 如果(X - 前面的黑帽數)>0, 叫"黑帽", 如果(X - 前面的黑帽數)=0, 則叫"白帽".
case2)犧牲者叫"白帽時". let X=(n-2)/2, 每當後面有人叫"白帽"時, X:=X-1. 輪到自己叫的時候, 如果(X - 前面的白帽數)>0, 叫"白帽", 如果(X - 前面的白帽數)=0, 則叫"黑帽".
就是這樣.
e.g.
WBWBBB
WWWBWWWW, n=14
first one(W): see B=5, W=8, so B
second one(B): he knows X=(14-2)/2=6 in his mind, and he see B=4 in front, so 6-4=2>0, he shout "Black"{survive}
third one(W): X:=X-1=6-1=5, he see B=4 in front, so 5-4=1>0, he shout "Black"{die}
4th one(B): X=5-1=4, he see B=3 in front, 4-3=1>0, he shout "Black" {survive}
5th one(B): X=4-1=3, he see B=2 in front, 3-2=1>0, he shout "Black" {survive}
6th one(B): X=3-1=2, he see B=1 in front, 2-1=1>0, he shout "Black" {survive}
7th one(W): X=2-1=1, he see B=1 in front, 1-1=0, he shout "White" {survive}
8th one(W): X=1-0=1, he see B=1 in front, 1-1=0, he shout "White" {survive}
9th one(W): X=1-0=1, he see B=1 in front, 1-1=0, he shout "White" {survive}
10th one(B): X=1-0=1, he see B=0 in front, 1-0=1>0, he shout "Black" {survive}
11 th one(W): x=1-1=0, he see B=0 in front, 0-0=0, he shout "White"{survive}
12 th one(W): x=0, he see B=0 in front, 0-0=0, he shout "White"{survive}
13 th one(W): x=0, he see B=0 in front, 0-0=0, he shout "White"{survive}
14 th one(W): x=0, he see B=0 in front, 0-0=0, he shout "White"{survive}
今次14人有2個死掉, 也算不錯. 注意那個 {(X - 前面的黑帽數)>0} 的statement. (X - 前面的黑帽數)是不會(也沒可能)少於0 的.
現在一個較極端的情況,
e,g,
WWWWWWWWWWWWWW, n=12
1 st one:(W) see B=0
2nd one (W): X=(12-2)/2=5, B=0 in front, so 5-0=5>0, shout"Black"{die}
3rd one (W): X=5-1=4, B=0 in front, so 4-0=4>0, shout"Black"{die}
4th one (W): X=4-1=3, B=0 in front, so 3-0=3>0, shout"Black"{die}
5th one (W): X=3-1=2, B=0 in front, so 2-0=2>0, shout"Black"{die}
6th one (W): X=2-1=1, B=0 in front, so 1-0=1>0, shout"Black"{die}
7th one (W): X=1-1=0, B=0 in front, so 0-0=0, shout"White"{survive}
8th one (W): X=0, B=0 in front, so 0-0=0, shout"White"{survive}
9th one (W): X=0, B=0 in front, so 0-0=0, shout"White"{survive}
10th one (W): X=0, B=0 in front, so 0-0=0, shout"White"{survive}
11th one (W): X=0, B=0 in front, so 0-0=0, shout"White"{survive}
12th one (W): X=0, B=0 in front, so 0-0=0, shout"White"{survive}
12人死了6個.
這方法的生還率算式是這樣的:
m=population, n=m-1
S=summation(i=0, (n-1)/2) [nCi]
T=summation(j=0, (n-1)/2) [((n+1)/2+j)*(nCj)/S]
expectation(average survive percentage)= (T+1/2)/m
所以
expectation=81% when population=4
expectation=84% when population=6
expectation=67% when population=12
expectation=72% when population=52
原來今次Expextation是決定於出現"或者死亡者"有多少情況會死.
今次在結論上也許不被上次(expectation->83.33%)成功, 但給予了我們一些新的觀點.
下次便要宣佈令人震撼的正解了.