Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- #function for getting coordinates given an angle
- def get_cartesian_coords(nums):
- theta = nums
- x = np.cos(theta)
- y = np.sin(theta)
- return [x,y]
- #generate random starting coordinate
- angle = np.random.uniform(-np.pi, np.pi)
- coordinates = get_cartesian_coords(random_angle)
- amplitudes = [abs(coord) for coord in coordinates]
- random_walk = [amplitudes]
- for _ in range(9999):
- #generate random small change in angle
- direction = 0.01 * np.random.uniform(-1, 1)
- angle += direction
- coordinates = get_cartesian_coords(angle)
- amplitudes = [abs(coord) for coord in coordinates]
- random_walk.append(amplitudes)
- timestep = list(range(20000))
- #create sequence using generated amplitudes
- sequence = list(map(lambda i: np.round((((random_walk[i][0])*-1)*np.sin((0.0002)*i)) + \
- ((random_walk[i][1])*np.sin(0.0002*i)))+ 100 + np.random.normal(0, 0.01),decimals=2),timestep)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement