Suppose you take a random walk of n steps on average how


Extend the random walk program from Chapter 9 (Programming Exercise 12) to keep track of how many times each square of the sidewalk is crossed. Start your walker in the middle of a sidewalk of length n where n is a user input, and continue the simulation until it drops off one of the ends. Then print out the counts of how many times each square was landed on.

Exercise 12:

A random walk is a particular kind of probabilistic simulation that models certain statistical systems such as the Brownian motion of molecules. You can think of a one-dimensional random walk in terms of coin flipping. Suppose you are standing on a very long straight sidewalk that extends both in front of and behind you. You flip a coin. If it comes up heads, you take a step forward; tails means to take a step backward.

Suppose you take a random walk of n steps. On average, how many steps away from the starting point will you end up? Write a program to help you investigate this question.

Request for Solution File

Ask an Expert for Answer!!
Basic Computer Science: Suppose you take a random walk of n steps on average how
Reference No:- TGS01704963

Expected delivery within 24 Hours