为什么statsmodels的相关函数和自相关函数在Python中给出了不同的结果?

2024-07-05 14:49:29 发布

您现在位置:Python中文网/ 问答频道 /正文

我需要得到两个不同序列A和B之间的相关性以及A和B的自相关关系。利用statsmodels提供的相关函数,我得到了不同的结果,计算A的自相关和计算A和A之间的相关性是不一样的,为什么结果不同?。在

下面是我所说行为的一个例子:

import numpy as np
from matplotlib import pyplot as plt
from statsmodels.tsa.stattools import ccf
from statsmodels.tsa.stattools import acf

#this is the data series that I want to analyze
A = np.array([np.absolute(x) for x in np.arange(-1,1.1,0.1)])

#This is the autocorrelation using statsmodels's autocorrelation function
plt.plot(acf(A, fft=True))

enter image description here

^{pr2}$

enter image description here


Tags: thefromimport利用关系isasnp