伪逆的手动计算与Matlab中的pinv不同 [英] manual calculation of pseudo inverse is not same as pinv in matlab

查看:332
本文介绍了伪逆的手动计算与Matlab中的pinv不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个矩阵D为m * n,我正在使用公式inv(D'* D)* D'计算伪逆,但它没有产生与pinv(D)相同的结果.我需要增量操作的术语inv(D'* D).我所有的准确性取决于不正确的inv(D'* D).是否有其他方法可以准确获得inv(D'* D)?有人可以帮我吗?

I had a matrix D which is m*n and i am calculating the pseudo inverse using the formula inv(D'*D)*D' but it is not generating the same result as pinv(D).I need the term inv(D'*D) which i require for incremental operation. My all accuracy depends upon inv(D'*D) which is not correct. Is there any alternate way to get inv(D'*D) accurately? can any one help me please?

%D是我从一个博客复制而来的3x4矩阵,仅用于演示目的.实际上,我的原始版本中的一个也存在相同的问题,因为它的尺寸太大,我无法在此处发布.

% D is 3x4 matrix that i had copied from one blog just for demonstration purpose. Actually original one of mine also had same problem bu its size is too large that i can't post it here.

D = -[1/sqrt(2) 1 1/sqrt(2) 0;0 1/sqrt(2) 1 1/sqrt(2);-1/sqrt(2) 0 1/sqrt(2) 1];

    B1 = pinv(D)
    B2 = D'*inv(D*D')

    B1 =

      -0.353553390593274   0.000000000000000   0.353553390593274
      -0.375000000000000  -0.176776695296637   0.125000000000000
      -0.176776695296637  -0.250000000000000  -0.176776695296637
       0.125000000000000  -0.176776695296637  -0.375000000000000

    Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND =
    1.904842e-017. 

    B2 =

      -0.250000000000000                   0   0.500000000000000
      -0.500000000000000                   0                   0
       0.250000000000000  -0.500000000000000                   0
                       0                   0  -0.750000000000000

我需要inv(D'D)进行增量操作.实际上,在我在步骤1中遇到的问题中,每次将新行添加到D的最后一个位置,而在步骤2中,D的第一行将被删除.所以我想使用我在这两个步骤之前计算出的逆来找到最终的D逆.更精确地在这里看看:

I need inv(D'D) to do incremental operation. Actually in my problem at step 1, each time a new row will be added to the last position of D and in step 2 first row of the D will be removed. So i want to find final D inverse using the inverse which i calculated before these two steps. More precisely have a look here:

B = inv(D'*D); % if i can calculate it accurately then further work is as follows
D1 = [D;Lr];  %Lr is last row to be added
BLr = B-((B*Lr'*Lr*B)/(1+Lr*B*Lr')); % Row addition formula
Fr = D1(1,:); % First row to be removed 
D2 = removerows(D1,1);
BFr = BLr+ ((BLr*Fr'*Fr*BLr)/(1-Fr*BLr*Fr')); % row deletion formula
B = BFr;
Y = BFr*D2;

推荐答案

您用于摩尔-彭罗斯(Moore-Penrose)的公式(D ^ TD)^-1 D ^ T或D ^ T(DD ^ T)^-1仅当D具有完整的列或完整的行秩时,伪逆才有效.

The formulae (D^T D)^-1 D^T or D^T (D D^T)^-1 you are using for the Moore-Penrose pseudoinverse are only valid if D has full column or full row rank, respectively.

在您的情况下,情况并非如此,因为警告矩阵接近单数".

This is not true in your case, as the warning "Matrix is close to singular" shows.

即使矩阵既没有完整的行列也没有完整的列秩,matlab pinv命令适用于任意D.

The matlab pinv command works for arbitrary D, even if the matrix has neither full row or full column rank.

这篇关于伪逆的手动计算与Matlab中的pinv不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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