A*x=y当A不可逆如何解x

# 问题解决

``````# 求解系数
import numpy as np
a= np.random.randn(2,3)
a2=( np.random.randn(2,3))*1j
a=a+aa
print(a)
B = np.linalg.pinv(a)
print(B) # B为a的伪逆矩阵
# np.allclose(a,b) 判断是不是精确解
# np.allclose(a, np.dot(a, np.dot(B, a)))
# np.allclose(B, np.dot(B, np.dot(a, B)))
``````

@是矩阵的乘法运算符，python>=3.5可用

a@B是一个单位矩阵
B@a也是单位矩阵

146个模式，每个模式有3个分量，每个模式取3个位置

(146,3,3)的数据

# 小插曲

（1,146）@(146,3,3) = (3,3)

### 将三个点的三个分量变为9个值

(1,146)@(146,9) = (1,9)

## 所有的代码如下

``````# encoding=utf-8
# such as the problem below
# you have x,y and you know k*x=y
# you want to get k

import numpy as np
# x is your data,below i random get x
x= np.random.randn(146,3*3)+( np.random.randn(146,3*3))*1j

# k is of course is (146,1) data
# result is data y the above have said
result = np.random.randn(1,3*3)+np.random.randn(1,3*3)*1j
a_t = np.linalg.pinv(x)

# k is the answer you get !
k= np.dot(result,a_t)
``````
原文作者：a_rose_for_tang
原文地址: https://blog.csdn.net/a_rose_for_tang/article/details/112687566
本文转自网络文章，转载此文章仅为分享知识，如有侵权，请联系博主进行删除。