Created
September 13, 2017 07:25
-
-
Save Kaundur/d313c614f01bcb2f2b7270b9b0fd2993 to your computer and use it in GitHub Desktop.
Simple simulation of the Monty Hall problem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
switch_choice = 0 | |
stay_choice = 0 | |
samples = 100000 | |
for i in range(samples): | |
selected_door = random.randint(0, 2) | |
correct_door = random.randint(0, 2) | |
if selected_door == correct_door: | |
stay_choice += 1 | |
else: | |
switch_choice += 1 | |
print 'Switch: ' + str(switch_choice/float(samples)) + '%' | |
print 'Stay: ' + str(stay_choice/float(samples)) + '%' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment