SHARE
TWEET

Untitled

a guest Feb 22nd, 2020 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3. from itertools import starmap
  4. from functools import reduce
  5.  
  6.  
  7. def signal(x, amp=1.0, omega=1.0, phi=0):
  8.     return amp * np.sin(x * omega - phi)
  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(
  18.     [(x, 2.0, phi_i, 0) for phi_i in [12.0, 11.5, 8.5]]
  19. )
  20.  
  21. sigma = 0.3 * max(xx)
  22. result_sig = xx + np.random.normal(0, sigma, len(xx))
  23.  
  24. plt.plot(result_sig, label='Шум')
  25. plt.plot(xx, label='Исходный')
  26.  
  27. plt.legend()
  28. plt.show()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top