Monty Hall problem: Difference between revisions
Content added Content deleted
m (one variable eliminated) |
|||
Line 1,701:
<lang Mathematica> montyHall[nGames_] :=
Module[{r, winningDoors, firstChoices, nStayWins
r := RandomInteger[{1, 3}, nGames];
winningDoors = r;
firstChoices = r;
nStayWins = Count[Transpose[{winningDoors, firstChoices}], {d_, d_}];
nSwitchWins = nGames - nStayWins;
Grid[{{"Strategy", "Wins", "Win %"}, {"Stay", Row[{nStayWins, "/", nGames}],
{"Switch", Row[{nSwitchWins, "/", nGames}], 100 - stayWinPercent}}, Frame -> All]]</lang>
|