import numpy as np import matplotlib.pyplot as plt import seaborn as sns sns.set(style='white', palette='colorblind', context='talk') cpal = sns.color_palette('colorblind') import numpy as np def random_walk_on_sphere(n, T, epsilon=0.05): # Initialize the position on the sphere position = np.random.randn(n) position /= np.linalg.norm(position) # Path of the random walk path = [position.copy()] for _ in range(T): # Generate a small random perturbation perturbation = np.random.randn(n) * epsilon # Move to the new position new_position = position + perturbation # Normalize to stay on the sphere new_position /= np.linalg.norm(new_position) position = new_position # Store the position path.append(position.copy()) return np.array(path) # Example of a random walk on a 3-dimensional sphere with 100 steps n = 20 T = 100 path = random_walk_on_sphere(n, T) sns.heatmap(np.corrcoef(path))