def find_maxima(input_list): """Find local maxima of x. Input arguments: x -- 1D list of real numbers Output: idx -- list of indices of the local maxima in x """ local_maxima = [] for i, val in enumerate(input_list): if i == 0 or i == len(input_list)-1: continue if input_list[i-1] < val and input_list[i+1] < val: local_maxima.append(i) if len(input_list) > 0: if input_list[0] > input_list[1]: local_maxima.append(0) if input_list[-1] > input_list[-2]: local_maxima.append(len(input_list)-1) return sorted(local_maxima)