Advertisement
Doc_Morg

Untitled

Nov 15th, 2019
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. if __name__ == '__main__':
  2. N = 30
  3. T = 4
  4. D = 2
  5. x = np.random.uniform(low=-1, high=1, size=N)
  6. x[0] = 1
  7. x = np.cumsum(x)
  8. print(x)
  9. index = []
  10. mins = argrelextrema(x, np.less)[0]
  11. maxs = argrelextrema(x[mins[0]+T:], np.greater)[0]
  12. index.append(mins[0])
  13. i = 0
  14. for j in range(maxs.shape[0]):
  15. if maxs[j] - mins[i] >= D and j - i >= T:
  16. index.append(maxs[j])
  17. for i in range(1, mins.shape[0]):
  18. if maxs[j] - mins[i] >= D and j - i >= T:
  19. index.append(mins[i])
  20. break
  21. print(mins, '\n', maxs)
  22. print(index)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement