Question: Answer question 14 using Python 3, and the graphics import 12. A random walk is a particular kind of probabilistic simulation that models certain statistical
Answer question 14 using Python 3, and the graphics import

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. 13. Suppose you are doing a random walk (see previous problem) on the blocks of a city street. At each "step" you choose to walk one block (at random) either forward, backward, left or right. In n steps, how far do you expect to be from your starting point? Write a program to help answer this question. 14. Write a graphical program to trace a random walk (see previous two problems) in two di mensions. In this simulation you should allow the step to be taken in any direction. You can generate a random direction as an angle off of the x axis. angle - random) 2 math.pi The new x and y positions are then given by these formulas x -x + cos (angle) y-y + sin(angle) The program should take the number of steps as an input. Start your walker at the center of a 100x100 grid and draw a line that traces the walk as it progresses
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
