Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. import numpy as np
  2. #function for getting coordinates given an angle
  3. def get_cartesian_coords(nums):
  4. theta = nums
  5. x = np.cos(theta)
  6. y = np.sin(theta)
  7. return [x,y]
  8. #generate random starting coordinate
  9. angle = np.random.uniform(-np.pi, np.pi)
  10. coordinates = get_cartesian_coords(random_angle)
  11. amplitudes = [abs(coord) for coord in coordinates]
  12. random_walk = [amplitudes]
  13. for _ in range(9999):
  14. #generate random small change in angle
  15. direction = 0.01 * np.random.uniform(-1, 1)
  16. angle += direction
  17. coordinates = get_cartesian_coords(angle)
  18. amplitudes = [abs(coord) for coord in coordinates]
  19. random_walk.append(amplitudes)
  20. timestep = list(range(20000))
  21. #create sequence using generated amplitudes
  22. sequence = list(map(lambda i: np.round((((random_walk[i][0])*-1)*np.sin((0.0002)*i)) + \
  23. ((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