我实在是太固执了,一直觉得主持人开碗之前是1/3,开碗之后换不换都是1/2,但是实验告诉我错了。
%change or not N = 3; change = true; Total = 10000; count = 0; for i = 1:Total car = randi(N); %rand(randi(10)); %伪随机数问题 first_choose = randi(N); %打开N-2个没有汽车的门 if (first_choose == car) lefted = mod(car + 1,N)+1; %如果一开始就猜对了,则随便留一个 else lefted = car; %如果一开始猜错了,只能留汽车了 end if (change) last_choose = lefted; else last_choose = first_choose; end count = count + (last_choose==car); end str = ['不', '换']; fprintf('换不换? %s: 正确率:%f
',str(change+1), count/Total);
实验结果是:
换不换? 换: 正确率:0.667300
本站所有内容均为互联网搜索引擎提供的公开搜索信息,本站不存储任何数据与内容,任何内容与数据均与本站无关,如有需要请联系相关搜索引擎包括但不限于百度,google,bing,sogou 等
© 2025 tinynews.org All Rights Reserved. 百科问答小站 版权所有