我找不到为什么计算两个系列A和B之间的相关性numpy.correlate给出的结果与我得到的结果不同的原因statsmodels.tsa.stattools.ccf
以下是我提到的这种差异的一个例子:
import numpy as np
from matplotlib import pyplot as plt
from statsmodels.tsa.stattools import ccf
#Calculate correlation using numpy.correlate
def corr(x,y):
result = numpy.correlate(x, y, mode='full')
return result[result.size/2:]
#This are the data series I want to analyze
A = np.array([np.absolute(x) for x in np.arange(-1,1.1,0.1)])
B = np.array([x for x in np.arange(-1,1.1,0.1)])
#Using numpy i get this
plt.plot(corr(B,A))
Run Code Online (Sandbox Code Playgroud)
#Using statsmodels i get this
plt.plot(ccf(B,A,unbiased=False))
Run Code Online (Sandbox Code Playgroud)

结果看起来质量上有所不同,这种差异来自哪里?