Wednesday 25 August 2021

Random Walks

Suppose an ant starts at the origin or (0,0) in the Cartesian coordinate system and moves one unit at a time upwards or sideways but only to the right. This binary choice is made randomly. Figure 1 illustrates the situation and shows that the ant will end up after three moves at either P, Q, R or S.


Figure 1

Suppose a boundary is imposed beyond with the ant cannot proceed. This boundary is marked by the lines \(x=100\) and \(y=100\). If the ant reaches this boundary, its motion stops. In effect, the ant's path is confined to 100 x 100 grid of squares. The four central squares are (50, 50), (50, 51), (51, 50) and (51, 51). The ant's movement also stops if it reaches any of these central squares. With its current movement constraints, it can only reach the first three of these central squares.

I thought that I'd write a program in SageMath to simulate the ant's journey whose path will terminate either at the boundary or at one of the four central squares. Figure 2 shows a journey at ends at the boundary.


Figure 2: permalink

Figure 3 shows a journey that ends at one of the four central squares.


Figure 3: permalink

It's easy enough to modify the program that different restraints are imposed on the ant's movements. For example, as well as moving upwards or to the right, it could also be allowed to move diagonally upwards. The resulting motion is similar but tends to drive it more toward the line \(y=x\) as shown in Figures 4 and 5 where the path reaches the boundary and the central squares respectively.


Figure 4: permalink



Figure 5: permalink

My simple programming activity was stimulated by watching a YouTube video that simulated lightning strikes and was more complex and written in Mathematica.


It is interesting to explore the probability that the ant will be stopped in the centre of the grid. Over 10,000 trials, I found that when the ant has three possible movements (up, right and diagonally up), the likelihood of being stopped in the centre is a little under 8.5% and never below 8% in my testing. Permalink. When only up and right movement is allowed, the likelihood is definitely lower with percentages ranging a little above and a little below 8%. Permalink.


It's interesting to experiment with different types of movements. An example is a restricted knight move where the ant can move two up and one to the right or one up and two to the right. Figures 6 and 7 show examples of the two possible paths. The likelihood of the ant's journey being stopped in the centre is fairly tightly centred on 8%.


Figure 6: permalink




Figure 7: permalink

There's plenty of scope for further experimentation but I'd best leave off there.

No comments:

Post a Comment