【问题标题】:autocorrelation matrix with order in PythonPython中具有顺序的自相关矩阵
【发布时间】:2020-05-14 18:42:11
【问题描述】:

我有一个 lpc 分析所需的滞后自相关矩阵方程:

我写了方法:

def autocorr_matrix(x,order):
    R = numpy.zeros((order, order))
    for i in range(0,order):
        for j in range(0,order):
            R[i,j] = autocorrelate(x, abs(i-j))
    return R
def autocorrelate(x,lag):
    return numpy.correlate(x[0:len(x)-lag],x[lag:len(x)])

这是正确的解决方案吗?有人知道我如何测试这些方法的结果吗?

【问题讨论】:

  • 这能回答你的问题吗? Estimate Autocorrelation using Python
  • 谢谢,但没有。作为结果的链接是无限的自相关向量。在我的等式中是受 lpc 顺序限制的矩阵

标签: python matrix lpc autocorrelation


【解决方案1】:

要测试您的结果,您可以使用两种方法:

1- 创建两个带相移的 sin 信号,看看您的代码是否可以测量相关性。

2- 使用一些可信赖的库进行关联并检查您的结果。 我正在使用的库是“statsmodel”: statsmodel.org

from statsmodels.tsa.stattools import acf,ccf

acf 用于自相关,ccf 用于互相关。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-15
    • 1970-01-01
    • 1970-01-01
    • 2022-08-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多