R 中的广义逆
我可以使用 MASS 库中的 ginv 函数来获取矩阵的 Moore-Penrose 广义逆。
m <- matrix(1:9, 3, 3)
library(MASS)
ginv(m)
在 SAS 中,我们确实有多个函数来获取矩阵的广义逆。 SVD 可用于求广义逆,但这又是 Moore-Penrose。我想知道除了 Moore-Penrose 广义逆之外,R 中是否还有任何函数可以获取矩阵的广义逆(这不是唯一的)。预先感谢您的帮助和时间。
编辑
矩阵 A 的广义逆定义为任意矩阵 G 满足方程 AGA = A。
该 G 不是 Moore-Penrose 广义逆,因此它不是唯一的。
I can use ginv
function from MASS
library to get Moore-Penrose Generalisied Inverse of a matrix.
m <- matrix(1:9, 3, 3)
library(MASS)
ginv(m)
In SAS we do have more than one function to get a generalized inverse of a matrix. SVD can be used to find the generalized inverse but again this is a Moore-Penrose. I wonder if there any function in R to get a generalized inverse of a matrix (which is not unique) other than Moore-Penrose Generalisied Inverse. Thanks in advance for your help and time.
Edit
A generalized inverse of a matrix A is defined as any matrix G that
satisfies the equation AGA = A.
This G is not a Moore-Penrose Generalisied Inverse so it is not unique.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
大多数时候,您并不真正需要矩阵的逆,因为在完成时,最终结果可能会因舍入错误而被破坏。
更典型的是使用部分旋转和缩放来创建 LU 分解。用它对右侧向量进行前向/后向替换以获得解决方案。如果您有多个 RHS 向量,这尤其有用,因为您可以重复应用它。
您需要 Matrix 包来执行此操作。
Most of the time you don't really want the inverse of a matrix, because the end result can be ruined by rounding errors by the time you're done.
It's more typical to create the LU decomposition using partial pivoting and scaling. Use it to perform forward/back substitution on right-hand-side vector to get the solution. This is especially helpful if you have multiple RHS vectors, because you can apply it repeatedly.
You need the Matrix package to do this.
是的,确实,R 软件包不再可用,这带来了很大的不便。或者,您可以使用
pracma
包。还有摩尔-彭罗斯广义逆:
Yes true, it's a great inconvenience R packages are no longer available. Alternatively you can use the
pracma
package.And your Moore-Penrose Generalisied Inverse: