Random walk

author: Vinicius Placco (http://vmplacco.github.io/)


Random walk is a stochastic process that has applications in many different
areas. It is essentially described as a succession of random steps (integers,
floats) on a given parameter space. Applications include the movement of
molecules in a gas, population genetics, fluctuating stock prices, Markov
chains, Brownian motion, behavioral psychology, among many others!



This first example shows a friendly competition between four "walkers". The goal is to reach the farthest distance from the center after 2,000 steps. The walkers start at (0,0) and each step "i" within [0:2000] is given by:

(xi+1,yi+1) = (xi,yi) + (Δxy)

where Δx and Δy are random floats in the [-0.05:0.05] interval with five decimal places.



The black filled symbols show the current position of the walkers and the gray symbols denote the maximum distance from the center. The circles are drawn for easier visualization. In this case, green-walker won. I ran 1,000 competitions and, not surprisingly, the winning fractions for the four walkers are 22% (blue), 25% (red), 26% (green), and 27% (yellow). Below is another example of the same simulation with a different outcome.



The second example below is a more "traditional" random walk. In this case, there are six walkers and they can only move vertically or horizontally, having one of four choices of steps: (0,1), (0,-1), (1,0), and (-1,0).



The third example goes back to the steps with varying sizes in both directions. The axis in both panels are independent, which helps visualize the steps of different sizes.



The next video is just a single walker going for 5,000 steps, not much else...



The last video is just an experiment with one walker always on the center of the parameter space. It is a little harder to follow but I think it gives a better idea on how stochastic the process really is!



Made with bash + gshuf + gnuplot + convert + ffmpeg
https://en.wikipedia.org/wiki/Random_walk