Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2020
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3. from itertools import cycle, starmap
  4. from functools import reduce
  5.  
  6.  
  7. def signal(x, amp=1.0, phi=1.0, theta=0):
  8. return amp * np.sin(x * phi - theta)
  9.  
  10.  
  11. def sum_signal(param_set):
  12. return reduce(lambda a, x: a + x, starmap(signal, param_set))
  13.  
  14.  
  15. x = np.linspace(-2 * np.pi, 10.0 * np.pi, 400)
  16.  
  17. xx = sum_signal(zip(
  18. cycle([x]), cycle([2.0]), [12.0, 11.5, 8.5], cycle([0])
  19. ))
  20.  
  21.  
  22. sigma = 0.3 * max(xx)
  23. result_sig = xx + np.random.normal(0, sigma, len(xx))
  24.  
  25. plt.plot(result_sig, label='Шум')
  26. plt.plot(xx, label='Исходный')
  27.  
  28. plt.legend()
  29. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement