Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

U is .66. if my iterations is 1 and I win 1 time Then my returned value is 1. lf my iterations is 4 andl

image text in transcribed
U is .66. if my iterations is 1 and I win 1 time Then my returned value is 1. lf my iterations is 4 andl dont win any games then my returned value is t}. I The way to determine if a game has been won is to look at whether the door that the player chose is the "car\" and the switch parameter is False or if the alternate door is the "car\" and the switch parameter is Tme. If those conditions are met then it counts as a win. We will want to keep track of how many times we win and lose given how many iterations we are anning and calculate the nal win percentage. This script should contain an \"if name I main" statement where you create an instance of simulation with 3 doors and you print the returned value from calling the play_game method. This instance should invoke the play _game method with switch as False and iterations as 100. I l{ZZIne note: You may be so inclined to test your code using more iterations, keep in mind, this takes a lot of computational power. Be weary of adding too many {is into your script. A sweet spot is 1DDD. You should notice that your returned value is somewhere near .66 for this instance. I lCreate a scn'pt named visualization. This script should import monty_hall, pandas and seaborn. This script should create a class named Plot. -t. \\_, Plot should have 2 keyword parameters, doors {int} and simulations (int). Doors represents the amount of doors that a simulation instance will use simulations pertains to the amount of simulation instances that we will create. Plot should also create an attribute named sequence that will be a list that will eventually contain dictionaries that we will use to create a dataframe later. F'Iot should then contain a loop that will run for as many times as the value of simulations. Starting at 1, the loop will determine if the current iteration is odd or even. If even the loop should create an instance of simulation from the monty_hal[ namespace and invoke the play _game method. it will pass in the number of doors when created, then pass in switched as True and iterations will be passed in using the current iteration that we are on. if the current iteration number is odd then it will do the same thing but it will create an instance of simulation where the switched value is False. Using the returned percentage, the loop will append a dictionary to the sequence attribute where the keys are "iterations\" {what our current iteration is), \"percentage\" (our returned percentage value), "doors" {how many doors our simulation uses} and "switched" {our boolean as a string representing whether we switched the door or not. After the loop is completed we will call the make JJIUt method by passing in the sequence attribute. I For example: Lets say that my simulations parameter is 3. I will start at 1 and create that simulation instance where my iterations argument for the play _game method is 1 and append that dictionary to the list. I will then go to 2 and do the same where the iterations argument is 2. I will then do to 3 and do the same where the iterations argument is 3 and stoo

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

Unity From Zero To Proficiency Beginner A Step By Step Guide To Coding Your First Game

Authors: Patrick Felicia

1st Edition

1091872023, 978-1091872028

More Books

Students also viewed these Programming questions