Is there any numpy autocorrellation function with standardized output?

后端 未结 2 2026
孤独总比滥情好
孤独总比滥情好 2020-12-30 10:56

I followed the advice of defining the autocorrelation function in another post:

def autocorr(x):
    result = np.correlate(x, x, mode = \'full\')
    maxcorr         


        
2条回答
  •  [愿得一人]
    2020-12-30 11:13

    So your problem with your initial attempt is that you did not subtract the average from your signal. The following code should work:

    timeseries = (your data here)
    mean = np.mean(timeseries)
    timeseries -= np.mean(timeseries)
    autocorr_f = np.correlate(timeseries, timeseries, mode='full')
    temp = autocorr_f[autocorr_f.size/2:]/autocorr_f[autocorr_f.size/2]
    iact.append(sum(autocorr_f[autocorr_f.size/2:]/autocorr_f[autocorr_f.size/2]))
    

    In my example temp is the variable you are interested in; it is the forward integrated autocorrelation function. If you want the integrated autocorrelation time you are interested in iact.

提交回复
热议问题