系统在计算上是单数的:R中的倒数条件数 [英] System is computationally singular: reciprocal condition number in R

查看:1770
本文介绍了系统在计算上是单数的:R中的倒数条件数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

x <- matrix(rnorm(80, mean = 0, sd = 0.1), 8, 8)
c <- cov(x)
solve(c)

我收到错误消息:

solve.default(c)中的错误:系统在计算上是单个的: 互惠条件编号= 6.57889e-18

Error in solve.default(c) : system is computationally singular: reciprocal condition number = 6.57889e-18

我一直在尝试找出问题背后的原因,并且Stack Overflow上的其他线程都认为该问题可能是由于奇异矩阵,高度相关的变量,线性组合等引起的.但是,我认为可以避免上述问题.

I have been trying to figure out what is the reason behind the problem, and other threads at Stack Overflow have suggested the issue might be due to singular matrices, highly correlated variables, linear combination etc. However, I assumed that rnorm would avoid the mentioned problems.

对于我正在使用det()的另一个矩阵给出8.313969e-95,但对于solve()仍然是可逆的.

For another matrix that I am working with det() gives 8.313969e-95, but it is still invertible with solve().

推荐答案

两个基本线性代数属性:

Two fundamental linear algebra properties:

  1. 奇异(方形)矩阵是不可逆的(方形)矩阵.
  2. 矩阵的行列式等于零是不可逆的.

如果您检查

set.seed(2018);
x <- matrix(rnorm(80, mean = 0, sd = 0.1), 8, 8)
c <- cov(x)
det(c)
#[1] -3.109158e-38

因此,det(c)确实为零(在机器精度范围内);因此c不可逆,这正是solve(c)试图做的.

So indeed, det(c) is zero (within machine precision); hence c is not invertible, which is exactly what solve(c) is trying to do.

PS 1:看一下?solve,看solve(a)将返回a的逆数.
PS 2:在交叉验证上有一个好帖子协方差矩阵行列式的解释.看一看,以了解为什么看到的内容.

PS 1: Take a look at ?solve to see that solve(a) will return the inverse of a.
PS 2: There exists a nice post on Cross Validated on the interpretation of the determinant of the covariance matrix. Take a look to understand why you're seeing what you're seeing.

这篇关于系统在计算上是单数的:R中的倒数条件数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆