【问题标题】:Linearly independent matrix in pythonpython中的线性无关矩阵
【发布时间】:2020-08-26 13:10:40
【问题描述】:

我有一个 15714 x 541 的矩阵,而且这个矩阵似乎不是线性独立的。如何删除不是线性独立的列?

我尝试使用这篇文章中的这个解决方案: elimination the linear dependent columns of a non-square matrix in python

但是,它说: ValueError:项目错误长度为 541 而不是 15714。

Q, R = np.linalg.qr(fixeff.T)
fixeff[np.abs(np.diag(R))>=1e-10]

fixeff 是我描述的矩阵。

【问题讨论】:

    标签: python linear-algebra


    【解决方案1】:

    您可以使用scipy.linalg.qr

    from scipy.linalg import qr
    
    Q, R, P = qr(A, mode="economic", pivoting=True)
    inv = P.argsort() # reversed order (necessary here)
    good_columns = (np.abs(np.diag(R)) > 1e-10)[inv]
    
    A = A[:,good_columns]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-10-20
      • 1970-01-01
      • 2021-11-12
      • 1970-01-01
      • 1970-01-01
      • 2021-05-23
      • 1970-01-01
      • 2020-12-05
      相关资源
      最近更新 更多