Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- doors = [1,2,3]
- nb_simulations = 1000000
- win_door1 = 0
- win_door2 = 0
- for i in range(nb_simulations):
- winning_door = random.choice(doors)
- player_door1 = random.choice(doors)
- # Open a door
- doors_openable = doors.copy()
- doors_openable.remove(player_door1)
- if player_door1 != winning_door:
- doors_openable.remove(winning_door)
- doors_opened = random.choice(doors_openable)
- # Change ?
- doors_selectable = doors.copy()
- doors_selectable.remove(doors_opened)
- doors_selectable.remove(player_door1)
- player_door2 = doors_selectable[0]
- if winning_door == player_door1:
- win_door1 += 1
- if winning_door == player_door2:
- win_door2 += 1
- freq_win_door1 = win_door1 / nb_simulations
- freq_win_door2 = win_door2 / nb_simulations
- if 0.33 < freq_win_door1 < 0.34 and 0.66 < freq_win_door2 < 0.67:
- print(True)
- else:
- print(False)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement