Random Walks

Basic Concepts of Generative Arts: Random Walks

Have you ever taken a stroll through a bustling city, wandering down streets without a specific destination in mind? Imagine that each step you take is determined by chance, leading you down unexpected paths and through unforeseen twists and turns. This seemingly aimless journey is a metaphorical representation of a mathematical concept known as a “random walk.”

Random walks are captivating mathematical models that find applications in a multitude of fields, from finance and physics to biology and computer science. In this introductory exploration, we’ll embark on a fascinating journey into the world of random walks, unveiling the beauty hidden within the seemingly chaotic nature of randomness.

One of the intriguing aspects of random walks is their diverse range of applications. In finance, random walks serve as the foundation for modeling stock prices, capturing the inherent uncertainty and unpredictability of the market. The famous “random walk hypothesis” suggests that stock prices follow a random path, making it impossible to predict future movements with certainty.

Beyond the realm of finance, random walks play a crucial role in physics, particularly in understanding the motion of particles. Brownian motion, a specific type of random walk, explains the erratic movement of microscopic particles suspended in a fluid. Albert Einstein himself contributed to this field by providing a theoretical explanation for Brownian motion, earning him the Nobel Prize in Physics in 1921.

Random walks also offer a unique lens through which we can view the natural world. Biological systems often exhibit behavior that can be modeled using random walks, such as the foraging patterns of animals or the movement of molecules within a cell. By applying mathematical principles to these phenomena, scientists gain valuable insights into the underlying mechanisms of life.

In this blog series, we will delve deeper into the intricacies of random walks, exploring different types, their mathematical foundations, and their real-world applications. Whether you’re a seasoned mathematician, a curious student, or someone intrigued by the beauty of randomness, there’s something captivating about the unpredictable paths that random walks reveal.

Understanding the Basics

At its core, a random walk is a mathematical concept that describes a path consisting of a series of random steps.

It basically is a mathematical abstraction that mirrors the unpredictability of real-world processes. Imagine taking a series of steps, each determined by a random choice of direction—left, right, forward, or backward. The cumulative effect of these chance-driven steps creates a path that embodies the essence of randomness. This concept finds applications across diverse fields, from finance to physics and biology, offering insights into the dynamic and often unpredictable nature of various phenomena.

Pseudocode Illustration:

# Pseudocode for a simple 1D random walk
initialize position at the origin
initialize number of steps

for step in range(number_of_steps):
# randomly choose a direction (left or right)
direction = random.choice([-1, 1])

# take a step in the chosen direction
position = position + direction

# print the current position
print(“Step:”, step+1, “Position:”, position)

Starting at the left and walking towards the right side using the pseudocode above and iterating results in the following images:

One random walk.

Basic concepts - random walks - n=1, w=1023

Five random walks.

Basic concepts - random walks - n=5, w=1023

Ten random walks.

Basic concepts - random walks - n=9, w=1023

A lot more random walks.

Basic concepts - random walks - n=30x2, w=1023

The last image looks a lot like pencil strokes and could be used as starting point to simulate pencil drawings. It might need more layers with lower alpha (transparency) each but the concept goes into the right direction. (Details to be published in the upcoming article How to Generate Pencil Strokes.)

A similar approach can be used to simulate crayons by using colors.

simulating crayons in generative art simulating crayons in generative art

Random Walks from Shapes

Let’s start playing with random walks in generative art with random walks from shapes. The first shape we’re looking at is a circle, and one gets mesmerizing results like the one below.

ao-pedesis II: aops-r0.125-10000ao-pedesis II: aops-r0.125

Details about the process of generating images from random walks using a circle as a sampling base can be found in my recent article Random Walks from Shapes: Circles.

Another variation are random walks from grids.

pedesis I (study): random walks 2x2 nodes in dark mode pedesis I (study): random walks 3x3 nodes in dark mode

Randomizing the grid gives us images which look a lot like maps to the stars.

random walks: starlight (21 nodes, 28k walks) random walks: starlight (11 nodes, 28k walks)

« »