added local maxima function
This commit is contained in:
parent
952f8b97a5
commit
c62e1e8797
3 changed files with 56 additions and 4 deletions
|
@ -4,12 +4,18 @@ def find_maxima(x):
|
|||
Input arguments:
|
||||
x -- 1D list of real numbers
|
||||
|
||||
|
||||
Output:
|
||||
idx -- list of indices of the local maxima in x
|
||||
"""
|
||||
return []
|
||||
maxima = []
|
||||
for index in range(len(x)-2):
|
||||
if x[index+1] > x[index] and x[index +1] > x[index+2]:
|
||||
maxima.append(index+1)
|
||||
|
||||
return maxima
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
x = [1, 2, 3]
|
||||
x = [1, 2, 2, 1]
|
||||
print(find_maxima(x))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue