Question: IN PYTHON: Write a Python simulation to experimentally verify the Monty Hall problem. Your simulation should run a large number of trials for two scenarios:

IN PYTHON:

Write a Python simulation to experimentally verify the Monty Hall problem. Your simulation should run a large number of trials for two scenarios: staying with the original door, and changing the door. For each scenario, report the number and percentage of wins over all of the trials.

Simulation algorithm (for each trial) for staying with the original door:

a. Randomly place the car b. Have the player randomly choose one of the three doors c. Determine whether the player won

Note that the above scenario does not require accounting for which door is opened, since the player is not going to alter his/her original choice.

Simulation algorithm (for each trial) for changing the door: d. Randomly place the car e. Have the player randomly choose one of the three doors f. Open a losing door (besides the players original choice) g. Change the players choice to the one remaining door h. Determine whether the player won

Python hint: Pythons randint(a, b) function (also located in the random module) returns a random integer N such that a N b.

The Monty Hall problem is a counterintuitive example of how probability works. Heres the premise: You are on a game show where you have to pick one of three closed doors. Behind one of these doors is a new car, and behind the other two are goats. Once youve picked a door, the shows host (who knows the winning door) opens one of the other doors to reveal a goat and asks if youd like to change your choice. To maximize your chances of winning the car, should you change or stay with your original door?

The probability that you originally picked the winning door is obviously 1/3. This means that the probability you originally picked a losing door is 2/3. However, if you originally picked a losing door and change your choice after the host opens the other losing door, you are guaranteed a win! (Remember that the door opened by the host is always a losing door.) Thus, if you always change your choice, the probability that you win is the same as the probability that you initially picked a losing door. This is 2/3 much better than sticking with your original choice!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!