Question: Write a Python script for the above scenario. Programming Assignment (Simulating the Drunkard's Walk): Once, when three college students had gathered at The Origin Pub,

Write a Python script for the above scenario.
Programming Assignment (Simulating the Drunkard's Walk): Once, when three college students had gathered at The Origin Pub, the following conversation was heard: "Imagine that drunk over there, walking around in a city which is completely ordered into a square grid. Suppose that, at each one-block intersection, he randomly chooses one of the four directions in which to proceed (including the direction he just came from)." The Stats major asked: "I wonder, what is the probability that he would ever reach his home?" The Math student added: "And I'm curious: on average, how far from the Origin might he have traveled after k steps (blocks)?" The Computer Science geek answered: "Dudes, I can simulate and visualize his walk on my laptop. This problem is more formaly known as a Random Walk, it's a fundamental model for stochastic (i.e. random) behavior. It is used in physics to simulate Brownian motion, in mathematics to help find solutions to Laplace's equation, and in economics to model stock price fluctuations Let's try to answer the students' questions. Simulate Consider a Cartesian plane. Assume the drunk begins his walk at the origin. Write a script to: . Visualize the Drunkard's Walk 1. prompt the user for k, the number of steps (blocks) the drunk should take 2. simulate a Random Walk 3. graph (display) the trajectory of the walk To facilitate the visualization, use an implementation of Turtle Graphics, which is included with Python. Turtle graphics provides simple access to a number of "Etch-a-Sketch"-type operations that make it easy to create simple drawings. Simply import the appropriate module: from turtle import *
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
