Question: answer code please Part I - Using Monte Carlo to simulate a game of chance Suppose we have a game where thee are 100 tals

answer code please
answer code please Part I - Using Monte Carlo to simulate a

Part I - Using Monte Carlo to simulate a game of chance Suppose we have a game where thee are 100 tals wht numbers 1 frough 100 . The rules af the game ae simple. II you diaw a bat wth a nurber 52.53,,190 then you winc othervise the house whi. We can rasly compute the probabilty of einong - Piryer has 49 eut of too chances of wining so probekity a 0.43 - Hount has 51 out of too ehavcel of wiming se preeitilfy a 6.51 Cearly the hecent has an edge which we can conpute uting the expected satit it you bet $700 then the enpected vatue expectedvalue=(3443(4,49)=(124)(251)=8,42(180)=2 So with thin bet, you should expect to lose ti per gaxe. The goal is to approximate your ending funds e yoe decidn you an only poing to pley a certan number of games. For exarpie, wippose you are only going to piny 5 times then we cold aimulate the game for 5 limes. Howere, this mould only geve is the mnaning tunde for one asanple of playing 5 games. initoad iwe mart to do tha mary smes are aiengh thic mult. Astume that the utarting fundw are 510,000 and we almup waper 15100 per pame. We soleve this problem in the following steps: - Step Q. impot icrary and set soed - Step 1, Deline a turction which rehumi fien et the player wies ane fine othamise. * step 2. Define a turcton which simulaten plyying Aee garce a given number of tmes; it unes the function in slep 1 and adpets the find avalable depending it the player wins or losen. Finction meums the amount of funde memaning after plopeng tie pies number of tmes and the number of times the player wisloses. * Step 3. Wite code to call the tunction in Step 2 tor 3 ganes. Outsu the tands renaing aher 5 pares and number of wishloses. - Step 4, Modify the code in Step 4 to do this simuicon lat playng 5 gumed 100 times. Oucput the average of the fund merraing atee 5 games and the probubilty of whring s lowing: output the expected value tor thes wimidstion The newits you get in Steg 4 do NOT match our theonteal ecoected value of lowng th per game is clowe to the theowtical value. 26. 111t 4 import. rashe Hifeary and set seed in 1114 ineg: and 700 in 1+ : f rhen recerin tree if Phayer q. ving and tetume ralse If doine wita. unctiob A Aar ieven otatesenes to tunction remaining ahar these 5 gamet. the decrete pesboblty of winitg a lat the tatal number at wins ever al wimidriens doubed ty the tatal number of parmes simulated loeing about 's? per garnt What do we need to do to grt a beper aporesimation? Modfy the necessary statemensief in your popgam and pertarm ancther simubon to pot araind baing 62 per game

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!