Reference no: EM132355259
Question
In this problem, we will be writing pieces to simulate the Monty hall problem. Monty Hall was the host of "Let's Make a Deal" in the 1960's and 70's.
The problem can be summarized by the following:
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, 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 host must always open a door that was not picked by the contestant.
The host must always open a door to reveal a goat and never the car.
The host must always offer the chance to switch between the originally chosen door and the remaining closed door.
The typical problem is for 3 doors but we can easily extend it to any number of doors. The simulation for this problem can be designed in different ways. However, we will focus our design using Python's dictionary and string objects along with some basic concepts of probability theory.
Caveat for the whole notebook - This problem specifically deals with probabilities and simulations. Wherever required, we have implemented 99.7% confidence intervals for checking your answers. Do keep in mind that there is a probability (very small) that your answer lies beyond this interval. In such a scenario, you might want to re-run the test cell.
Exercise 0 Complete the function initialize_game() which has 1 input argument:
n: The total number of doors
The function will place a car behind one of the n doors randomly and uniformly (following Uniform Distribution).
The function returns a dictionary with:
keys as strings in the pattern 'Door x', where 1≤x≤n
1≤x≤n, and
values as either the string 'Goat' or the string 'Car'.
There can only be one 'Car' in the dictionary. All the other values shall be 'Goat'.
Example: For n = 5, 'Car' can be behind any door from 'Door 1' to 'Door 5'. In this case, 'Car' is behind 'Door 2', the function should return:
{'Door 1': 'Goat', 'Door 2': 'Car', 'Door 3': 'Goat', 'Door 4': 'Goat', 'Door 5': 'Goat'}