Skip to content

Instantly share code, notes, and snippets.

@Kaundur
Created September 13, 2017 07:25
Show Gist options
  • Save Kaundur/d313c614f01bcb2f2b7270b9b0fd2993 to your computer and use it in GitHub Desktop.
Save Kaundur/d313c614f01bcb2f2b7270b9b0fd2993 to your computer and use it in GitHub Desktop.
Simple simulation of the Monty Hall problem
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