【发布时间】:2014-10-05 21:48:48
【问题描述】:
我有一个 4x4 矩阵,我认为它应该作为正定传递,但是使用 is.positive.defined(),它的评估结果为假。当我使用 nearPD() 计算最近的正定矩阵时,结果矩阵用 is.positive.defined() 计算为正定矩阵,但看起来相同。
矩阵是这样的
1 1 0 0
1 1 0 0
0 0 1 1
0 0 1 1
其中 x'Mx 应计算为 (x1+x2)^2 + (x3+x4)^2,这似乎满足正定条件。
无论如何,这是代码。有谁知道我在这里有什么遗漏吗?
library(Matrix)
library(matrixcalc)
D = rbind(c(1,1,0,0),c(1,1,0,0),c(0,0,1,1),c(0,0,1,1))
##evaluates false
is.positive.definite(D)
d = nearPD(D)$mat
d = matrix(d, nrow = 4)
## looks the same as D
d
##but evaluates to positive definite
is.positive.definite(d)
【问题讨论】:
-
如果 x1 = -x2 且 x3 = x4 = 0,则二次形式的计算结果为 0。
-
函数
is.positive.definite定义在哪个包中?
标签: r matrix linear-algebra