Is there a numpy builtin to reject outliers from a list

后端 未结 10 776
孤城傲影
孤城傲影 2020-11-28 18:00

Is there a numpy builtin to do something like the following? That is, take a list d and return a list filtered_d with any outlying elements removed

10条回答
  •  旧巷少年郎
    2020-11-28 19:01

    This method is almost identical to yours, just more numpyst (also working on numpy arrays only):

    def reject_outliers(data, m=2):
        return data[abs(data - np.mean(data)) < m * np.std(data)]
    

提交回复
热议问题