2. The Monty Hall Problem: Here we will investigate this famous probability phenomenon. Sup- pose you're on a game show,
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
2. The Monty Hall Problem: Here we will investigate this famous probability phenomenon. Sup- pose you're on a game show,
2. The Monty Hall Problem: Here we will investigate this famous probability phenomenon. Sup- pose 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, 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?" Write a simulation in python of the Monty Hall problem based on two strategies. One where you always switch and one where you always stay at your first choice door. Do this for 10,000,000 (10 million) trials. What is the experimental probability in each case? Does the outcome agree with your calculation of the theoretical probability?
# # Monty Hall Problem Simulation import numpy as np from numpy.random import randint countsWin 0; countsLose num Trials = 100000 = # = for i in range(numTrials): L = [1, 2, 3] carDoor = randint(1, 4) yourDoor = randint(1, 4) # use conditionals to check if your door is = car door and keep a running tally