1

mahalanobis跑步时出现以下错误

Error in solve.default(cov, ...) : 
  Lapack routine dgesv: system is exactly singular: U[2,2] = 0

这是我的代码。

calibration <- 10
mean <- colMeans(x[1:calibration,])
sx <- cov(x[1:calibration,])
d <- mahalanobis(x[1:calibration,], mean, sx) 

这是数据

1 0.7071068
0 0.0000000
2 1.4142136
2 1.4142136
0 0.0000000
0 0.0000000
2 1.4142136
1 0.7071068
1 0.7071068
0 0.0000000

我怎样才能避免这个错误?

4

0 回答 0