矩阵没有通过正定

时间:2014-08-12 17:45:19

标签: r matrix linear-algebra

我有一个4x4矩阵,我相信它应该作为正定,但是使用is.positive.definite(),它正在评估为false。当我使用nearPD()计算最近的正定矩阵时,得到的矩阵用is.positive.definite()求值为正定,但看起来相同。

矩阵看起来像这样

 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)

1 个答案:

答案 0 :(得分:2)

矩阵不是正定的。 From Wikipedia

在线性代数中,如果对于n个实数的每个非零列向量z,zTMz为正,则称对称n×n实矩阵M为正定。

考虑向量(-1,1,-1,1)。它非零,只包含实数。

但是(-1 + 1)^ 2 +( - 1 + 1)^ 2 = 0,它不大于零。所以矩阵不是正定的。但矩阵是正半正定