为什么绘制归一化自相关会给出正值和负值?

问题描述

我使用以下代码为数组计算和绘制自相关函数ACF,如下所示:

an_array = [1,2,3,4,5]
autocorrelation = np.correlate(an_array,an_array,mode="full")
ACF= autocorrelation[autocorrelation.size//2:]
print(ACF)

输出

[55 40 26 14 5]

然后,我计算出归一化的ACF如下:

normalized_ACF = (ACF- ACF.min(axis=0)) / (ACF.max(axis=0) - ACF.min(axis=0)) 
print(normalized_ACF)

输出

[1。 0.7 0.42 0.18 0。]

输出正确。

但是,当我使用另一种使用python中内置函数“ plot.acf”的方法来计算和绘制数组的规范化ACF时,它会为我提供其他值(正值和负值),如下所示。

from statsmodels.graphics import tsaplots
# display the autocorrelation plot of your time series
fig = tsaplots.plot_acf(an_array,lags=3)
plt.show()

第二种方法输出

enter image description here

谁能解释为什么这两种方法给出不同的输出

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)