蒙提霍爾問題完全解析
問題背景
1963 年,美國電視節目《Let's Make a Deal》主持人 Monty Hall 設計了一個遊戲:三扇門後藏有一個大獎,另外兩扇是空的。你選一扇門後,主持人會打開一扇「確定是空的門」,再問你要不要換。
直覺 vs 數學
直覺告訴我們:剩下兩扇門,換不換都是 50%。
數學告訴我們:換門勝率是 2/3 ≈ 67%,不換只有 1/3 ≈ 33%。
條件機率解釋
結論:換門等於把 2/3 的機率押注在「我第一次選錯了」,這個假設是正確的!
程式驗證(Python)
import random
def simulate(n_games=100000, switch=True):
wins = 0
for _ in range(n_games):
doors = [0, 0, 1] # 1 = 大獎
random.shuffle(doors)
choice = random.randint(0, 2)
# 主持人打開一扇空門
host_opens = next(
i for i in range(3) if i != choice and doors[i] == 0
)
if switch:
choice = next(i for i in range(3) if i not in [choice, host_opens])
if doors[choice] == 1:
wins += 1
return wins / n_games
print(f"換門勝率:{simulate(switch=True):.1%}") # ≈ 66.7%
print(f"不換勝率:{simulate(switch=False):.1%}") # ≈ 33.3%上方遊戲累積遊玩夠多次後,你會看到統計數字逐漸收斂到 2/3 與 1/3 — 這就是「大數法則」的力量。