I have come across this problem which was apparently very famous some years ago, in which a person is placed in front of 3 doors: one of them has a stack of gold behind it, and the other two have nothing. The question is whether the person should switch doors or not before opening one. Apparently, the answer is one should always switch doors.
In order to check this, I have written a small piece of code in which I run $10^6$ iterations. In each of them, I shuffle the doors, make a choice of door and then switch to another door (randomly). I add +1 point if I hit the stack of gold and $0$ if I don't. Finally, I count all the successful iterations and divide it by the total number of iterations. If the proposed result is correct, I should get $\frac{pts.}{N}>1/3$. Nonetheless, I see it converges to this value. What am I not getting? Here is my code:
import numpy as np pts = 0 doors = np.array([0,0,1]) N=1000000 for i in range(N): np.random.shuffle(doors) choice1 = np.random.randint(0, 3) # This is the first choice, I should switch choice2 = np.random.choice([num for num in range(0,3) if num != choice1]) pts += doors[choice2] print(pts/N) Note: I have checked that the "doors" array is indeed shuffling in every iteration, the numpy method "shuffle" just returns None, so you don't need to re-assign it to the original array, it just acts on the memory address.