threshold): """ Parameters ---------- data : Numpy array threshold : float Returns ------- List of tuples where each tuple contains index number and anomalous value. """ #Covert raw data into the degree of abnormality avg = np.average(data) var = np.var(data) data_abn = [(x - avg)**2 / var for x in data] #Set the threshold of abnormality abn_th = stats.chi2.interval(1-threshold, 1)[1] #Abnormality determination result = [] for (index, x) in enumerate(data_abn): if x > abn_th: result.append((index, data[index])) return result