Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using MATHLAB SCRIPTING The theory for random walks form the basis of many stochastic simulations. For this lab, we will simulate a simple random walk

image text in transcribed

Using MATHLAB SCRIPTING

The theory for random walks form the basis of many stochastic simulations. For this lab, we will simulate a simple random walk on a 2D lattice. A simple analogy for this random walk is to imagine a drunk guy standing at the origin (0,0). He has an equal chance to move either north (0,1), south (0,-1), east (1,0) or west (1,0). (Recall the guy with amnesia having to find his way out of the mine and how he had an equal probability of any path because he couldn't remember). When the drunk guy renches his he can go in each of the I directions again with equal probability. This process is repeated indefinitely. For example, a random path can he (0,0) to (0,1) to (1,1) to (1.2) to (0,2) to (-12 new destination, the same choice is repeated anud One way to code this is MatLab is 1. Define a position matrix of size (N + 1) x 2, where N is the number of steps Initialize the first row to be (0,0] since he is starting at the origin. 2. Create a for loop which goes hroughach row from 1 to N. Use a ran. dom number generator, the current position (row i) and if else statements to decide the next position (row i+ This will be similar to the if-else statements and random number generators used in the miner lab 3. Once the loop is done, you should have the matrix for all of the positions at each step Problem 1 Plot these positions for one trial after N 10, 20. 100 steps. I.E plot(M(N 1,1),MIIN+12) where M is the matrix you just fled. These values of N will be a timestamp for his "progression" for this trial. Indicate the points after these steps (one way could be plot M(N,1),MN2)go)where "g could he replaced by any color, "o" by another symbol. For this trial, what is the maximal distance from the origin our drunkard has gone after 100 steps? Problem 2. For 1000 simulations (Mont Carlo), find the probability that after 100 steps, the person is ten or more units away from the origin in either direction. In other words, if the final coordinate is denoted (x.y). what is the probability tat 10 or ll10 after k simulations

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Relational Database And Transact SQL

Authors: Lucy Scott

1st Edition

1974679985, 978-1974679980

More Books

Students also viewed these Databases questions