|
Random walk by coin tossing Suppose that you are standing in the middle of a room facing north, as indicated by the green head with a nose pointing to north. If heads, you turn right 90° and take a step forward, or turn left 90° and take a step forward if tails, as denoted by the orange heads with H or T, respectively.
Figure 1 shows the path of {H, T, T, H, T} and you can extend it for the next 10 steps by coin tossing. Did you return to the starting position in figure 1? How about after 20, 30 or more steps?
Figure 1. Five steps by {H, T, T, H, T} This is called a random walk to simulate the zigzag path of a drunken person. When a ray of sun pierces through a window, we sometimes can see the dust particles floating in the air and their path of movement resembles a random walk. A pseudo-random number generator coded into Prog#7a simulates coin tossing. To facilitate visualization, Prog#7a displays the first 25% of random walk path in red, the second 25% in blue, the third 25% in green, and the last 25% in red. Also, the final location of random walk is indicated by a red
|