具有负特征值的正半定矩阵
据我所知,对于任何方实矩阵 A
,使用以下生成的矩阵应该是正半定(PSD)矩阵:
Q = A @ A.T
我有这个矩阵 A,它是稀疏且不对称的。然而,无论A
的属性如何,我认为矩阵Q
应该是PSD。
然而,在使用 np.linalg.eigvals 时,我得到以下结果:
np.sort(np.linalg.eigvals(Q))
>>>array([-1.54781185e+01+0.j, -7.27494242e-04+0.j, 2.09363431e-04+0.j, ...,
3.55351888e+15+0.j, 5.82221014e+17+0.j, 1.78954577e+18+0.j])
我认为复杂的特征值是由操作的数值不稳定性造成的。使用 scipy.linalg.eigh ,它利用了矩阵对称的事实,给出了
np.sort(eigh(Q, eigvals_only=True))
>>>array([-3.10854357e+01, -6.60108485e+00, -7.34059692e-01, ...,
3.55351888e+15, 5.82221014e+17, 1.78954577e+18])
同样包含负特征值的结果。
我的目标是对矩阵 Q 执行 Cholesky 分解,但是,我不断收到此错误消息,指出矩阵 Q 不是正定的,这可以通过上面显示的负特征值再次确认。
有谁知道为什么矩阵不是PSD?谢谢。
From what I know, for any square real matrix A
, a matrix generated with the following should be a positive semidefinite (PSD) matrix:
Q = A @ A.T
I have this matrix A, which is sparse and not symmetric. However, regardless of the properties of A
, I think the matrix Q
should be PSD.
However, upon using np.linalg.eigvals
, I get the following:
np.sort(np.linalg.eigvals(Q))
>>>array([-1.54781185e+01+0.j, -7.27494242e-04+0.j, 2.09363431e-04+0.j, ...,
3.55351888e+15+0.j, 5.82221014e+17+0.j, 1.78954577e+18+0.j])
I think the complex eigenvalues result from the numerical instability of the operation. Using scipy.linalg.eigh
, which takes advantage of the fact that the matrix is symmetric, gives,
np.sort(eigh(Q, eigvals_only=True))
>>>array([-3.10854357e+01, -6.60108485e+00, -7.34059692e-01, ...,
3.55351888e+15, 5.82221014e+17, 1.78954577e+18])
which again, contains negative eigenvalues.
My goal is to perform Cholesky decomposition on the matrix Q, however, I keep getting this error message saying that the matrix Q is not positive definite, which can be again confirmed with the negative eigenvalues shown above.
Does anyone know why the matrix is not PSD? Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当然,这是一个数值问题,但我想说
Q
可能仍然是 PSD。请注意,最大特征值是
1.7e18
,而最小特征值是3.1e1
,因此如果您采用min(L) + max(L),则比率约为== max(L)
将返回 true,这意味着最小值与最大值相比可以忽略不计。我建议你在稍微移动的矩阵版本上计算 Cholesky。
例如
Of course that's a numerical problem, but I would say that
Q
is probably still PSD.Notice that the largest eigenvalue is
1.7e18
while the smallest is3.1e1
so the ratio is about, if you take probablymin(L) + max(L) == max(L)
will return true, meaning that the minimum value is negligible compared to the maximum.What I would suggest to you is to compute Cholesky on a slightly shifted version of the matrix.
e.g.