-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproof.py
29 lines (21 loc) · 854 Bytes
/
proof.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import random
n = 100000 # number of times to run the estimation
woncar = 0
for i in range(n):
doors = [1,2,3]
car = random.randint(1,3)
choice = random.randint(1,3)
doors.remove(car) # remove for now to choose which one reveal
if(choice in doors):
doors.remove(choice) # dont reveal the choice
reveal = random.sample(doors,1)[0]
'''
Here is where you find the proof...
In the following we check if our other option which is != choice is the same as car.
Since the other non car options has been removed we only need to check if choice!=car
You can notice that we dont need lines 12-15
This is too obvious that the chance is 66% not 50%.
'''
if(choice != car):
woncar += 1
print("Chance that you win a car if you switch:", woncar/(i+1))