Module 9 5 Random Walk Angela B Shiflet
Module 9. 5 Random Walk Angela B. Shiflet and George W. Shiflet Wofford College © 2014 by Princeton University Press
Random walk • Random walk: apparently random movement of entity. In a time-driven simulation, we depict the entity in a cell on a rectangular grid. At any time step, the entity can move at random to a neighboring cell (possibly under certain constraints). • Cellular automaton (plural, automata) is type of computer simulation that is dynamic computational model and is discrete in space, state, and time • We picture space as grid, or one-, two-, or threedimensional lattice, or array, of sites (or cells).
Random walk • Cell of lattice has state • Number of states is finite • Rules, or transition rules, specifying local relationships and indicating how cells are to change state, regulate behavior of system • An advantage of such grid-based models is that we can visualize the progress of events through informative animations (a simulation of the movement of ants toward food source, or the spread of fire). • Brownian Motion: the behavior of a molecule suspended in a liquid. For example, pollen particle in liquid, pollutants in atmosphere and calcium in living bone tissue. • Simulations using random walks can model these processes. • In genetics, random walks have been used to simulate mutation of genes.
Algorithm for Random Walk •
• do the following n times: • let rand be a random 0 or 1 • if rand is 0 • increment x by 1 (meaning turning east) • else • decrement x by 1 (meaning turning west) • let rand be a random 0 or 1 • if rand is 0 • increment y by 1 (meaning turning north) • else • decrement y by 1 (meaning turning south) • append point (x, y) onto end of lst • return lst
Algorithm for Random Walk • Create and display graphics of random walk • Return distance between first and last points
Possible visualization • Display all points in blue except last point, which is red • Have lines connecting points • Wait to display until have everything • Display distance between first and last points • Input parameter is a list of n + 1 points, lst.
Algorithm Animate. Walk (lst)
Average Distance Covered •
Average Distance Covered
Average Distance Traveled Over num. Tests Number of Random Walks of n Steps Each
Relationships Between Number of Steps (n) and Distance Covered We execute mean. Random. Walk. Distance (n, 100) for values of n from 1 to 50, and store each average distance in a list or Array, list. Dist. Then we employ the techniques of Module 8. 3, “Empirical Models”, to determine the relationship.
- Slides: 12