Numpy的奇异矩阵问题 [英] Singular matrix issue with Numpy
本文介绍了Numpy的奇异矩阵问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将向量(3 x 1)乘以其转置(1 x 3).我得到了一个(3 x 3)数组,但是我无法得到它的逆矩阵.知道为什么吗?
I am trying to multiply a vector(3 by 1) by its transpose(1 by 3). I get a (3 by 3) array but I cannot get its inverse. Any idea why?
import numpy as np
c=array([1, 8, 50])
np.transpose(c[np.newaxis]) * c
array([[ 1, 8, 50],
[ 8, 64, 400],
[ 50, 400, 2500]])
np.linalg.inv(np.transpose(c[np.newaxis]) * c)
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "C:\Python26\lib\site-packages\numpy\linalg\linalg.py", line 445, in inv
return wrap(solve(a, identity(a.shape[0], dtype=a.dtype)))
File "C:\Python26\lib\site-packages\numpy\linalg\linalg.py", line 328, in solve
raise LinAlgError, 'Singular matrix'
LinAlgError: Singular matrix
推荐答案
您粘贴的矩阵
[[ 1, 8, 50],
[ 8, 64, 400],
[ 50, 400, 2500]]
行列式为零.这是奇异矩阵的定义(不存在逆矩阵)
Has a determinant of zero. This is the definition of a Singular matrix (one for which an inverse does not exist)
http://en.wikipedia.org/wiki/Invertible_matrix
这篇关于Numpy的奇异矩阵问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文