Answered step by step
Verified Expert Solution
Link Copied!

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

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

Algebra (subscription)

Authors: Elayn Martin Gay

6th Edition

0135176301, 9780135176306

More Books

Students also viewed these Mathematics questions

Question

An improvement in the exchange of information in negotiations.

Answered: 1 week ago

Question

1. Effort is important.

Answered: 1 week ago