Anonymous user
Monty Hall problem: Difference between revisions
→{{header|MATLAB}}
imported>Myrmidon (→{{header|Chapel}}: put the old version back too) |
imported>Grootson |
||
Line 3,031:
=={{header|MATLAB}}==
<syntaxhighlight lang="matlab">
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))
end</syntaxhighlight>
<syntaxhighlight lang="matlab">
function montyHall(numDoors,numSimulations)
assert(numDoors > 2);
|