【发布时间】:2017-04-17 15:51:40
【问题描述】:
模块 scikits.talkbox 包含一些用于 Levinson-Durbin 递归的 C 代码。不幸的是,这段代码在最新版本的 Python 中不起作用,我想用纯 Python 实现替换它。 (速度不是问题,只要它有效。)
损坏的 C 函数的文档字符串如下:
Levinson-Durbin recursion, to efficiently solve symmetric linear systems
with toeplitz structure.
Parameters
----------
r : array-like
input array to invert (since the matrix is symmetric Toeplitz, the
corresponding pxp matrix is defined by p items only). Generally the
autocorrelation of the signal for linear prediction coefficients
estimation. The first item must be a non zero real, and corresponds
to the autocorelation at lag 0 for linear prediction.
order : int
order of the recursion. For order p, you will get p+1 coefficients.
axis : int, optional
axis over which the algorithm is applied. -1 by default.
Returns
-------
a : array-like
the solution of the inversion (see notes).
e : array-like
the prediction error.
k : array-like
reflection coefficients.
Notes
-----
Levinson is a well-known algorithm to solve the Hermitian toeplitz
equation: ::
_ _
-R[1] = R[0] R[1] ... R[p-1] a[1]
: : : : :
: : : _ * :
-R[p] = R[p-1] R[p-2] ... R[0] a[p]
with respect to a. Using the special symmetry in the matrix, the inversion
can be done in O(p^2) instead of O(p^3).
Only double argument are supported: float and long double are internally
converted to double, and complex input are not supported at all.
我看到有一个函数scipy.linalg.solve_toeplitz 看起来像我想要的。但是,它无法指定顺序,而是将数组的元组作为输入。
我承认我在这里有点超出我的深度,并且不完全理解这段代码应该做什么。有没有一种简单的方法可以用 Numpy 的 solve_toeplitz 替换对损坏的 C 函数的调用?
【问题讨论】:
-
您是否只对solving a Toeplitz system 感兴趣(这是
scipy.linalg.solve_toeplitz所做的),还是在估计AR(p) process 的系数?
标签: python numpy scipy linear-algebra toeplitz