【发布时间】:2014-04-03 11:12:23
【问题描述】:
我正在编写一个脚本来在 MATLAB 中证明蒙蒂霍尔悖论,但我遇到了一个问题 - 不知道怎么让MATLAB生成一个和前面两个不同的1到3之间的随机数。
这是我的脚本:
% This program demostrates the Monty Hall paradox.
% A_pick1 represents where person chooses to put the five-pound note
% B_pick1 represents which box person B first identifies
% A_pick2 represents the box that person A opens up - it must be different
% than both A_pick1 and B_pick2
A_pick1 = round(3 * rand(1) + 0.5)
B_pick1 = round(3 * rand(1) + 0.5)
A_pick2 = round(3* rand(1) + 0.5);
while (A_pick2 == A_pick1 || A_pick2 == B_pick1)
A_pick2 = rand(3 * rand(1) + 0.5) ~= (A_pick1 && B_pick1)
break
end
我不确定如何正确使用 while 循环。
提前致谢
【问题讨论】: