Simulation Model
Run Simulation
Analyze Model
Model
Overview
View model equations
Current Model:
# Monte Carlo Simulation of the Monte Hall Problem. M StartTime = 1 M EndTime = 100 M ExecuteDecisionImmediately = TRUE R doors = 1..3 V Winning Door = INT(RAND * 3) + 1 P Winning Door.Documentation = "The winning door is either door 1, 2, or 3." D Initial Chosen Door = 1 V Remaining Doors[doors] = FOREACH(d, doors, IF(d = Winning Door, 0, IF(d = Initial Chosen Door, 0, 1) ) ) V Shown Door = IF(ARRAYSUM(Remaining Doors) = 2, IF(INT(RAND * 2) + 1 = 2, INDEXOF(1, Remaining Doors, INDEXOF(1, Remaining Doors) + 1), INDEXOF(1, Remaining Doors) ), INDEXOF(1, Remaining Doors) ) P Shown Door.Documentation = "When the player chooses the winning door, we want to randomly show one of the two doors that remain. If the winning door is different than the chosen door, then just show the door that isn't the winning door." D Change Door = 0 V Door to Switch to = INDEXOF(1, FOREACH(d, doors, IF(d = Shown Door, 0, IF(d = Initial Chosen Door, 0, 1) ) ) ) V Final Door Choice = IF(Change Door = 0, Initial Chosen Door, Door to Switch to) P Final Door Choice.Documentation = "If the player doesn't want to change the door, then keep the initial door, if the player wants to change then select the door that they didn't choose and that wasn't shown." V Player Won = IF(Final Door Choice = Winning Door, 1, 0) V Total Wins = ACCUM(Player Won)