Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

computer science major, data sci and applied Mach learn Section. please need help, answer step 4, 5, 6, and 7. already have step 1, 2,

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

computer science major, data sci and applied Mach learn Section. please need help, answer step 4, 5, 6, and 7. already have step 1, 2, and 3 but need help with the rest

Originating from the American TV program, "Let's Make a Deal," the Monty Hall problem gives a contestant a chance to win a car. There are three doors and behind one is a brand new car. The other two doors are hiding goats. The contestant chooses a door: the first, second, or third. Then the host Monty Hall opens up one of the other two doors remaining to reveal a goat. There are now two unopened doors, the one the contestant originally chose and the other un-opened door. Behind one is a goat and behind the other is a car. The contestant is given the option to stay with their originally-chosen door or to switch to the other door. Which should they do? Or does it not matter? Create a python simulation to answer this question. You may use the following seven steps as a guide, or you may develop your own. What matters is that you - Create a computer simulation that follows the Monty Hall problem, - Generate a Monte Carlo probability of winning a car for each of the choices of staying and switching doors, and - Provide a recommendation of whether the contestant should stay or switch doors. Step 1. (5 Points) Create a numpy array doors with the three possibiliites: goat one, goat two, and car. The contestant randomly chooses a door; simulate this by randomly choosing one of these three using np. random.choice () and calling it original_choice. [ ] ... Step 2. (5 Points) Now the host reveals a goat behind one of the two un-chosen doors. If the contestant had chosen a door with a goat behind it, then there is only one other door with a goat and that one will be opened by the host. If the contestant had chosen the door with the car behind it, then both un-chosen doors contain goats and the host will randomly decide which one to open. Simulate this. Call the goat-door the host reveals revealed_door . Hint: Use if statements. Step 3. (5 Points) Copy your code from Step 2 and modify it to assign what is left behind the third (un-chosen and un-revealed) door within the if statements, so as to be more computationally concise. Call this door the other_door. Step 4. (10 Points) Create a variable named choice that will simulate whether the contestant decides to stay with their original door or switch. choice will be either the string "stay" or "switch". Create a variable final_choice, which will be equal to original_choice if the contestant chose to stay, and equal to other_door if the contestant chose to switch. Step 5. (15 Points) Now you have everything you need to create a function monty_hall which will run one simulation of the game. The function will take one parameter, choice, and will return the final_choice of the contestant. Test your new function by calling it with both 'stay' and 'switch' and see if the contestant wins a goat or a car. 'car' Step 6. (20 Points) Find the probability of winning a car if the contestant chooses to stay with their original choice. Do this by running monty_hall('stay') 10,000 times, each time appending what the contestant won to a numpy array called winnings . Then count how many times the contestant won the car, and divide by how many trials there were, to arrive at the final odds of winning a car when choosing to stick with the original door. Call this winning_chance. Hint: Use a for loop. Step 7. (20 Points) Now find the probability of winning a car if the contestant chooses to switch doors (do the same thing as Step 6 but for the contestant choosing the other door)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Select Healthcare Classification Systems And Databases

Authors: Katherine S. Rowell, Ann Cutrell

1st Edition

0615909760, 978-0615909769

Students also viewed these Databases questions

Question

Provide examples of KPIs in Human Capital Management.

Answered: 1 week ago

Question

What are OLAP Cubes?

Answered: 1 week ago