Question: language = python In this problem, we'll simulate the simple random walk, perhaps the most important discrete-time stochastic process. Random walks are commonly used to

 language = python In this problem, we'll simulate the simple random

language = python

In this problem, we'll simulate the simple random walk, perhaps the most important discrete-time stochastic process. Random walks are commonly used to model phenomena in physics, chemistry, biology, and finance. In the simple random walk, at each timestep we flip a fair coin. If heads, we move foward one step; if tails, we move backwards. Let "forwards" be represented by positive integers, and "backwards" be represented by negative integers. For example, if we are currently three steps backwards from the starting point, our position is -3. Write random_walk to simulate a random walk. Your function should: O Take an upper and lower bound as inputs. Return three variables pos, positions, steps, in that order. pos is an integer, and indicates the walk's final position at termination. positions is a list of integers, and it is a log of the position of the walk at each time step. steps is a list of integers, and it is a log of the results of the coin flips. When the walk reaches the upper or lower bound, print a message such as Upper bound at 3 reached and terminate the walk. Your code should include at least one instance of an elif statement and at least one instance of a break statement. Hint To simulate a fair coin toss, try running the following cell multiple times. You don't have to use "heads" and "tails" when using this function -- can you think of a more useful choice set

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