Goat door Problem
Question: There are three closed doors, one with a car closed and the other two with goats. The host knows what is behind each door. First, the contestant chooses a door. Before opening the door, the host opens one door from the other two doors to reveal the goat behind the door. In this case, contestants are allowed to change their choices. Can contestants have the opportunity to guess a car after changing their choice? Please design and compile the program for verification and give your own explanations. The answer should be given in the following way.
A: I think it will increase the probability of selecting a car.
The reason is as follows: if the option is not changed, the probability of a car being guessed is 1/3. If the option is changed, if the option is selected for the first time, the probability of a car being selected is 1/3; if Yang 2 is selected for the first time, the probability of a car to be replaced is 1/3. If a car is selected for the first time, the probability of a car to be replaced is 0, the probability of a player guessing a car is 2/3.
The program source code is as follows:
Import random
X = eval (input ("enter simulation times :"))
Car = 0
Car1 = 0
For I in range (1, x + 1 ):
A = random. randrange (1, 4)
B = random. randrange (1, 4)
If a = B:
Car1 = car1 + 1
Elif! = B:
Car = car + 1
Print ("the probability of selecting a car after the change is", car/x)
Print ("do not change the probability of the selected car to", car1/x)
The verification result is as follows: