Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if __name__ == '__main__':
- N = 30
- T = 4
- D = 2
- x = np.random.uniform(low=-1, high=1, size=N)
- x[0] = 1
- x = np.cumsum(x)
- print(x)
- index = []
- mins = argrelextrema(x, np.less)[0]
- maxs = argrelextrema(x[mins[0]+T:], np.greater)[0]
- index.append(mins[0])
- i = 0
- for j in range(maxs.shape[0]):
- if maxs[j] - mins[i] >= D and j - i >= T:
- index.append(maxs[j])
- for i in range(1, mins.shape[0]):
- if maxs[j] - mins[i] >= D and j - i >= T:
- index.append(mins[i])
- break
- print(mins, '\n', maxs)
- print(index)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement