python 自相关函数_为什么statsmodels的相关性和自相关函数在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))

#This the autocorrelation using statsmodels's correlation function

plt.plot(ccf(A, A))

解决方法:

这两个函数对布尔无偏的参数有不同的默认参数.要获得与acf相同的结果(A,fft = True),请使用ccf(A,A,unbiased = False).

标签:python,numpy,statsmodels

来源: https://codeday.me/bug/20190629/1321174.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值