I have the following python script:
import numpy as np
import matplotlib.pyplot as plt
np.random.seed(123)
initialize and populate all_walks
all_walks = []
for i in range(5) :
random_walk = [0]
for x in range(100) :
step = random_walk[-1]
dice = np.random.randint(1,7)
if dice <= 2:
step = max(0, step - 1)
elif dice <= 5:
step = step + 1
else:
step = step + np.random.randint(1,7)
random_walk.append(step)
all_walks.append(random_walk)
Convert all_walks to NumPy array: np_aw
np_aw = np.array(all_walks)
Plot np_aw and show
plt.plot(np_aw)
plt.show()
Clear the figure
plt.clf()
Transpose np_aw: np_aw_t
np_aw_t =np.transpose(np_aw)
Plot np_aw_t and show
plt.plot(np_aw_t)
plt.show()
plt.clf()
I am trying to simulate a random walk and plot the graphs as you can see. The first plot looks like this :

The second one is this :
Clearly the correct image I was meaning to plot is the second but I didn't understand why I need to transpose the array ? and what does the first image represent ? I know it seems trivial but I don't want to skip over it without understanding what each one represents. Thanks for Any help in advance.
