Update : Code has been corrected.
Today I learnt about the Monty Hall Problem in my class. In short it is :
Suppose you’re on a game show, and you’re given the choice of three doors: Behind one door is a car; behind the others, goats. You pick a door, say No. 1 [but the door is not opened], and the host, who knows what’s behind the doors, opens another door, say No. 3, which has a goat. He then says to you, “Do you want to pick door No. 2?” Is it to your advantage to switch your choice?
The answer is change the door. When you change the door, you have 2/3 probability of getting the car.
So, as my sir suggested, I decided to simulate the problem writing a computer program. And it was verified! With the following program below :
When it was executed on my computer, the asnwers were: (It won’t give you the exact same values as it depends on a random number generator)
When 1 Billion simulations (Took 105 seconds to complete!) were conducted :
Wins when changed = 666659989
Wins when not changed = 333340011