Created
July 11, 2019 10:42
-
-
Save rch850/7a63be17a3940425de22343753fc5aff to your computer and use it in GitHub Desktop.
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
# Simulate Monty Hall Problem | |
# https://analytics-notty.tech/very-good-explain-montyhall-problem/ | |
import random | |
def game(change): | |
doors = [1, 2, 3] | |
bingo = random.choice(doors) | |
hand = random.choice(doors) | |
if change: | |
return hand != bingo | |
else: | |
return hand == bingo | |
n = 1000 | |
x = 0 | |
for i in range(n): | |
if game(True): x += 1 | |
print('If you change hand, ', x, 'wins in', n, 'games') | |
x = 0 | |
for i in range(n): | |
if game(False): x += 1 | |
print('If you do not change hand, ', x, 'wins in', n, 'games') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment