Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Can you please advise why my following python code is not working? I am trying to simulate a gambler's ruin i.e. random walk and I
Can you please advise why my following python code is not working? I am trying to simulate a gambler's ruin i.e. random walk and I don't understand why my code isn't working.
Code:
number_of_simulations = 10
prob = 0.5 initial_balance = 50
for i in range(number_of_simulations): gamblers_money = initial_balance while gamblers_money > -10000: gambler_win = np.random.uniform(0,1) < prob gamblers_money = gamblers_money + (gamblers_money*0.5) if gambler_win else gamblers_money - (gamblers_money*0.5)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started