📄 monty.m
字号:
%monty.m/created by PJNahin for "Duelling Idiots"(4/8/99)
%This m-file simulates 10,000 games of "Let's Make A Deal."
%
%
rand('state',100*sum(clock))
WNS=0; %initialize number of games won with NO SWTICHING;
WWS=0; %initialize number of games won WITH SWITCHING;
switch1=1/3;
switch2=2/3;
for game=1:10000
choice=rand; %put the prize behind one of the three doors;
if choice <= switch1
prize=1;
elseif choice <= switch2
prize=2;
else
prize=3;
end
choice=rand;
if choice <= switch1 %pick a door;
select=1;
elseif choice <= switch2
select=2;
else
select=3;
end
if select==prize %if prize is behind your selection, then ...
WNS=WNS+1; %you win prize if you DON'T switch;
else %if prize is not behind your selection, then ...
WWS=WWS+1; %you win prize if you DO switch;
end
end
WWS
WNS
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -