問題背景
1963 年,美國電視節目《Let's Make a Deal》的主持人 Monty Hall 設計了一個遊戲:
三扇門後面,一扇藏有大獎,另外兩扇是空的。
遊戲流程:你選一扇門 → 主持人打開一扇「確定是空的門」→ 你可以換或不換。
直覺上,換不換都是 50% 吧?錯了。
條件機率的解釋
第一次選門
你有 1/3 的機率選到大獎,2/3 的機率選到空門。
主持人的動作
主持人是「全知的」,他只會打開「非你選、且是空的門」。
換門勝率 = 2/3 ≈ 67%,不換勝率 = 1/3 ≈ 33%。
用程式驗證
import random
def simulate(n_games=100000, switch=True):
wins = 0
for _ in range(n_games):
doors = [0, 0, 1] # 1 = prize
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!