BL5229 Projects: Option 1 Simulation: The Monty Hall problem Marilyn vos Savant is famous for being the woman with the highest reported IQ (she is listed in the Guiness book of record for this). She maintains a column in an American magazine, “Parade”, in which she challenges people to submit questions for which she will provide answers. In 1991, she was asked the following question: “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 #1, and the host, who knows what's behind the doors, opens another door, say #3, which has a goat. He says to you, "Do you want to pick door #2?" Is it to your advantage to switch your choice of doors?” This question was named the “Monty Hall problem”, in reference to a TV game show, “Let’s make a deal” hosted by Monty Hall. Marilyn vos Savant answered that it is to your advantage to switch as it has a 2/3 chance of success, compared to 1/3 if you did not switch. Her answer however led to a large controversy, with more than 10,000 people writing to “Parade” (including many mathematicians) stating that her answer is wrong, as once a door has been revealed, each remaining door has a 50% chance of being the door with the car. Which of these two answers is right? We are going to simulate the Monty Hall problem with a Matlab program to try to solve this controversy. Below, I give you the frame of the program: complete it, implement it, and test it with different numbers of trials. Before we start: - The three doors will be numbered 1, 2, and 3. Note that with this scheme, the sum of the labels of the three doors is always 6. - We will use the Matlab function randi(N) to select a random integer number between 1 and N, as well as the Matlab function randperm(N) to generate a random permutation of the numbers between 1 and N. Matlab program: % % This small program simulates the Monty Hall problem % % It performs N dummy experiment and computes the chances of winning the car if we switch % the choice for the door, or not. % % Define number of trials, and initialize the number of wins, for switching or not: % Ntrial = 10000; Nwin_switch = 0; Nwin_noswitch = 0; % % Start trials % for i = 1:Ntrial % % Pick at random the door that corresponds to the car; store the corresponding % door number in the variable car, and the two remaining door numbers in the array % goat (size 2). % It is best to use the Matlab function randperm % car = goat(1) = goat(2) = % % % Pick a random door: initial choice of the user, and store in the variable choice. choice = % % % % % % Pick the door that Monty will open, which corresponds to a goat: if the user had picked the door with the car, Monty picks at random one of the two doors corresponding to a goat, while if the user had picked a door with a goat, Monty has only one choice. Name this door monty. monty = % % % Now checks if the user wins under two scenarios: % 2) The user switches to the remaining door: 1) The user keeps the door she had initially chosen: % end trials % end % % Compute probabilities: % proba_switch = 100*Nwin_switch/Ntrial proba_noswitch = 100*Nwin_noswitch/Ntrial Problem: - Complete the program above and run it for multiple values of Ntrial. Based on those results, should the use switch or not? Can you find a mathematical explanation for this? Extend this program such that it can deal with N doors, with 1 door corresponding to the car, and N-1 doors corresponding to goats. Once the user had picked one door, Monty opens N-2 doors with goats behind. Compute the probability of winning if the user decides to switch to the remaining door. Plot this probability as a function of N. Could you have predicted the result? Please provide both the source code of the program you wrote, and a report describing the results.
© Copyright 2026 Paperzz