Discussion about this post

User's avatar
VINOD VIJAYAN's avatar

import numpy as np

import matplotlib.pyplot as plt

# Parameters

num_steps = 1000

# Generate random walk data

x = np.zeros(num_steps)

y = np.zeros(num_steps)

for i in range(1, num_steps):

angle = np.random.uniform(0, 2 * np.pi)

x[i] = x[i-1] + np.cos(angle)

y[i] = y[i-1] + np.sin(angle)

# Plotting the random walk

plt.figure(figsize=(10, 10))

plt.plot(x, y, linestyle='-', marker='o', markersize=2, alpha=0.75, label='Random Walk')

plt.title('2D Random Walk')

plt.xlabel('X-axis')

plt.ylabel('Y-axis')

plt.show()

Expand full comment

No posts

Ready for more?