わかさぎのブログ

プログラミング、Atcoderの勉強とか

時系列データで初めて閾値超えた点の検出

        #R開始点は閾値を超えたところとして定義する
        thresh=[] ; threshold=np.average(y[0:100]+100)
        for i,j in enumerate(y):
            if j>threshold:
                thresh.append(i)
            else:
                pass

メモリの無駄遣いだが、thresholdを超えているなら空のリストに追加して、リストの先頭の要素を取り出せばよい。