Generating Images with Random Walks

2020-09-22codercfpart

The images below were produce by a small Haskell program using random walks. Random walk works like this. Start at position (x0, y0). Then add small random increments dx and dy, say in the range from -1 to +1 to get (x1, y1) = (x0 + dx, y0 + dy). Now generate new random numbers, also called dx and dy in the same range. Let (x2, y2) = (x1 + dx. y1 + dy). Do this many times to get a “random” sequence of points. Draw a little square at each of these points.

Random walk describes many physical phenomena, e.g., the diffusion of heat and the spread of perfume in still air. It also plays an important role in mathematical finance.

In the figures below, random walks were generated for a square region beginning at the origin. Several such images were generated, and one was chosen. The image was then cropped for artistic effect.

Figure A: one random walk

Figure B: two random walks

References