Question: 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

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 Mathematics Questions!