Improving Efficiency of Random Walker I'm seeing a web course of computational statistics, the first project consists of a random walker, the implementation I have done works as intended:
import numpy as np
import numpy.random as rd
import matplotlib.pyplot as plt

WALKER_STEPS: int = 5_000

# random orientation converted from degrees to radians
directions: np.array = rd.uniform(low=0, high=360, size=WALKER_STEPS) * np.pi / 180

x: list = [0]
y: list = [0]
idx: int = 0
for rad in directions:
    # updates the positions of the walker
    x.append(x[idx] + np.cos(rad))
    y.append(y[idx] + np.sin(rad))
    idx += 1

plt.plot(x, y)
plt.show()

I don't like the way I'm adding new elements to the lists x, y and I think that there's a more elegant way to do it.
Here a image of the result:

Note: I didn't do an abstraction because the exercise in small.
Use np.cumsum()
import numpy as np
import numpy.random as rd
import matplotlib.pyplot as plt
WALKER_STEPS: int = 5_000

# random orientation converted from degrees to radians
directions: np.array = rd.uniform(low=0, high=360, size=WALKER_STEPS) * np.pi / 180

x = np.cos(directions).cumsum()
y = np.sin(directions).cumsum()

plt.plot(x, y)
plt.show()