三门问题(Monty Hall problem)简析

问题内容:

你参加一档电视节目,节目组提供了ABC三扇门,主持人告诉你,其中一扇门后边有辆汽车,其它两扇门后是空的。

假如你选择了B门,这时,主持人打开了C门,让你看到C门后什么都没有,然后问你要不要改选A门?


问题答案:

要改。根据概率论的推导,在这种条件下,选A的命中率是2/3而选B的命中率是1/3。


分析:

很大一部分人在看到这个问题后的第一直觉都是换与不换一个样,命中率都应该是1/3,

或者说,在去掉了C这个选项之后,AB的命中率都应该是1/2才对。


这种想法似乎也没错,而且那个去掉的C也确实不符合我们大学时学的概率论的条件概率一说,那么问题到底出在哪里呢?


在这里,我有这样一种解释方法,希望可以帮助大家理解这个问题。

我们在计算概率的时候总要想一个全集的概念,也就是那个100%的概率1。

例如,在没有打开C门时,ABC的命中率都是1/3,那么全集就是A+B+C=1/3+1/3+1/3=1。

而打开C门之后,这个全集是什么呢?

我想,问题就出在这里。

通常的想法是A+B=1/2+1/2=1。那么这么想合适么?

按照A+B=1/2+1/2=1的计算方法,那么主持人问的就不应该是你要不要换,而是你在AB中再重新选择一次。

主持人问的是要不要换,所以这里的全集应该是“换+不换=1”,这就与A+B=1/2+1/2=1产生了区别。

换和不换,并不是1/2与1/2的关系,而是2/3与1/3的关系。这就是去除C带来的影响。


一个类似的问题与思考:

上边的分析个人感觉也很奇怪,因为换与不换和选A还是选B在本质上似乎并没有不同,但也只能理解到这个层次。

再拿一个类似的问题来佐证吧,

比如有100张彩票,其中只有一张有奖,你选了其中一张,

卖彩票的突然说,想帮帮你,去掉了其中50张没有奖的,现在问你,要不要重新选一次?

按通常的想法,原来的中奖率是1/100,若重新选一次,中奖率就是1/50。确实提高了。


Sure, I can help you with that. Here is the code to simulate the Monty Hall problem: ```python import numpy as np import matplotlib.pyplot as plt def random_door(): return np.random.choice([1,2,3]) def monty_choice(contestant_door, car_door): if contestant_door == car_door: return np.random.binomial(1, 0.5) + 1 else: return 6 - contestant_door - car_door def win_car(strategy, contestant_door, car_door, monty_door): if strategy == 'switch': new_door = 6 - contestant_door - monty_door return new_door == car_door else: return contestant_door == car_door def simulation(n, strategy): car_door = random_door() contestant_door = random_door() monty_door = monty_choice(contestant_door, car_door) successes = 0 failures = 0 for i in range(n): if win_car(strategy, contestant_door, car_door, monty_door): successes += 1 else: failures += 1 return successes, failures n = 1000 switch_successes, switch_failures = simulation(n, 'switch') noswitch_successes, noswitch_failures = simulation(n, 'noswitch') fig, axs = plt.subplots(1, 2, figsize=(10, 5), sharey=True) axs[0].bar(['Switch Successes', 'Switch Failures'], [switch_successes, switch_failures]) axs[0].set_title('Switch Strategy') axs[1].bar(['No Switch Successes', 'No Switch Failures'], [noswitch_successes, noswitch_failures]) axs[1].set_title('No Switch Strategy') plt.show() ``` This code defines three functions: `random_door` to randomly select a door for the car or the contestant, `monty_choice` to choose the door Monty opens based on the contestant's choice and the location of the car, and `win_car` to determine if the contestant wins the car based on the strategy (switch or no switch), the doors chosen by the contestant and Monty, and the location of the car. The `simulation` function runs the simulation for a given strategy and number of iterations. It selects the doors for the car and the contestant, chooses the door Monty opens, and then checks if the contestant wins the car based on the chosen strategy. The code then runs the simulation for both the switch and no switch strategies, and plots the results in side-by-side bar charts. According to the simulation results, the contestant should switch doors to increase their chances of winning the car. The switch strategy has a higher probability of success than the no switch strategy. This result is consistent with the conditional probability of the problem, which shows that the probability of winning the car is 2/3 if the contestant switches doors, and 1/3 if they do not switch.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值