Monty Hall problem: Difference between revisions

Content added Content deleted
imported>Grootson
imported>Grootson
Line 3,034: Line 3,034:
wins = ceil(3*rand(1e8,1)) - ceil(3*rand(1e8,1))
wins = ceil(3*rand(1e8,1)) - ceil(3*rand(1e8,1))
mprintf('chance to win for staying: %1.6f %%\nchance to win for changing: %1.6f %%', 100*length(wins(wins==0))/length(wins), 100*length(wins(wins<>0))/length(wins))
mprintf('chance to win for staying: %1.6f %%\nchance to win for changing: %1.6f %%', 100*length(wins(wins==0))/length(wins), 100*length(wins(wins<>0))/length(wins))
</syntaxhighlight>

OUTPUT:

<syntaxhighlight lang="matlab">
chance to win for staying: 33.334694 %
chance to win for changing: 66.665306 %
</syntaxhighlight>
</syntaxhighlight>