Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Let's suppose that we place an absorbing barrier at integer positions y = y < 0 and at y = yh> 0 below and

Let's suppose that we place an absorbing barrier at integer positions y = y < 0 and at y = yh> 0 below and

Let's suppose that we place an absorbing barrier at integer positions y = y < 0 and at y = yh> 0 below and above the starting position y = 0 respectively. An N-step walk starts at position 0 and continues until either completing N steps or hitting one of the two absorbing barriers, and then the walk ends. Write a function random_walk_with_barriers that returns a list (or numpy array) of values (positions) that the walk visits. The first value is 0 and the last value is an integer in the range [y, yh] it is y or yn if the walk gets absorbed, or strictly between the two if N steps are taken without absorption. random_walk_with_barriers (N, yl, yh) You can assume that the walk continues for no more than N steps. If the walk gets absorbed, the list that gets returned contains at most N + 1 values; if the walk doesn't get absorbed the returned list contains exactly N + 1 values. Here is a transcript where the lower absorbing barrier is placed at y = -3 and the upper absorbing barrier at y = 3. for in range (8): print (random_walk_with_barriers (8, -3, 3)) [ 0 -1 0 1 [ 0 -1 -2 -3] [ 0 -1 -2 -1 [ 0 -1 0 1 [0 1 2 1 2 3] [ 0 -1 -2 -1 [0 1 2 [0 1 1 0 1 0 -1 -2 -3] 0 -1 -2 -3] 2 1 0 -1 -2] 1 2 1 0] 0] 0] 0 0 -1 -2 -1 2 1 0 -1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

It seems that youve provided an image that describes a programming exerc... 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

Genetics Analysis And Principles

Authors: Robert Brooker

5th Edition

978-0073525341, 0073525340

More Books

Students also viewed these Programming questions

Question

4. Jobe dy -Y 2 et by

Answered: 1 week ago