Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

20 строки
443 B
Python

def find_anomalous_indices(X, M1, M2):
indices = []
for i in range(1, len(X)):
diff = X[i] - X[i-1]
if diff < M1 or diff > M2:
indices.append(i)
return tuple(indices)
def correct_anomalies(X, K):
X1 = X.copy()
for idx in K:
if idx == len(X) - 1:
X1[idx] = X1[idx - 1]
else:
X1[idx] = 0.5 * (X1[idx - 1] + X1[idx + 1])
return X1