Question: Plz solve correctly i will give good rating Task One gambler has a total budget of 1000 and they play a coin tossing game, where
Plz solve correctly i will give good rating
Task One gambler has a total budget of 1000 and they play a coin tossing game, where they can bet any amount for heads or fails. If their bet is successful, they retrieve their bet, plus winnings of an equal amount. That is, if they bet 1 and win, they will get 2. The gambler has come across what they think is a brilliant strategy to maximise their winnings. It consists in dividing their betting into "betting runs". Each run starts by betting l and always betting tails. If they win, they keep the winnings, add it to their budget and the run is finished. Then they can start another going back to bet 1. However, if they lose, their next bet will be double the previous, in this case 2. This means that, if they win, they will get 4, so their winnings will still be 1 (they spent 1 in the first bet and 2 in the second, 4 - 3 - 1). If they lose, they can keep doubling their bets again and again, and when they eventually win, the run finishes and their winnings will be of 1, after which they can start another run by betting 1. The gambler has tried this once with two betting runs and despite a worrying start, it has worked well. They've kept their record for you to see: Bet Number 1 2 3 4 5 6 7 Test finished Budget 1000 999 997 993 985 1001 1000 1002 Bet Amount 1 2 4 8 16 Bet type Tails Tails Tails Tails Tails Tails Tails Toss Result Heads Heads Heads Heads Tails Heads Tails Net Win/Loss -1 -2 -4 -8 16 -1 2 1 2 - Your task is to simulate this betting behaviour using Python. Starting with a 1000 budget, write a loop for a large number of bets (N). A fair coin toss can be simulated by generating a random number between 0 and 1 (with Numpy, for example) and assuming values in (0,0.5) represent tails and values in (0.5, 1) represent heads. Keep track of the budget and betting amount at each bet. If at any point the gambler needs to place a het higher than their current budget, they are not allowed to do so and the game should stop (even if it did not reach N bets). The current budget will then be their final budget. Your code should be able to answer the following questions: 1. If you simulate a thousand bets (N=1000), what is the final budget, the highest'lowest budget point during the game, and the highest bet ever placed? 2. If you do an experiment where you simulate M times the experiment above, what is the average final budget? How often the gambler has less money than when they started? 3. Are the results any different for questions 1 and 2 if N-10000? It should also be able to produce the following outputs: 1. A graph where the Y axes represents the budget level, and the X axis represents the bet number. 2. For each betting game, a table with the betting record similar to the one presented above. This must be saved to a CSV file with the name "betting record.csv". You might use either Numpy or Pandas functions to create this file. You should provide a short section in your report (800 words maximum) answering the questions above, including one example graph and one example output table (a screenshot of the CSV file is fine) and explaining the key features of your code used to solve this problem. Note that it is possible to solve this problem analytically, but your task is to implement the simulation as described above
Step by Step Solution
There are 3 Steps involved in it
To simulate the gamblers strategy and answer the questions we need to create a Python script to simulate coin tosses and track the budget and betting amounts Below is an example code using Python with ... View full answer
Get step-by-step solutions from verified subject matter experts
