pinv returned wrong solution

조회 수: 5 (최근 30일)
junqi yang
junqi yang 2017년 5월 6일
댓글: John D'Errico 2017년 5월 9일
I am trying to solve a equation:
a = Ae
Where a is a is 4 by 5 matrix , A is a 4 by 4 matrix and e is another 4 by 5 matrix
So I transfer the equation into
A = a * pinv(e)
to find the A,
When I justify my result by take A back to my equation with e, I got a completely different a
Here is what I did:
if true
a = x(1:5,:);
a(:,4) =1;
a
a = transpose(ref_p)
e = [0,0,0,1; 1,0,0,1; 0,1,0,1; 0,0,1,1; 1.17,-0.09, 4.2,1; ]
e = transpose(cano)
A = ref_p * pinv(cano)
cc = A * e
end
  댓글 수: 2
Wilson A N
Wilson A N 2017년 5월 9일
Can you please share the values you had used for 'ref_p', 'x' and 'cano'?
Jan
Jan 2017년 5월 9일
Please post the input values in a form, which can be used by the readers. Defining e explicitely and overwriting it in the next line looks at least confusing. You have defined a also and overwrite it later.

댓글을 달려면 로그인하십시오.

답변 (1개)

John D'Errico
John D'Errico 2017년 5월 9일
It is not that pinv returns the "wrong" solution, but in your understanding of the problem.
I don't have enough of your variables to reconstruct your problem. What is x, what is ref_p, what is cano? Regardless, e is non-square, and 4x5. You are trying to solve the problem
a = A*e
(By the way, learn to use variable names that make sense. One letter variable names, a,A,e, etc., are BAD ideas. They lead to confusing code. They lead to bugs.)
a is 4x5
A is 4x4
e is 4x5
There is no exact solution to the problem in general. So the solution will be a least squares solution, minimizing the sum of squares of errors.
Again, this is not a problem with pinv. There is no matrix A that will yield an exact solution. So the result is the best possible, over all matrices A, that minimizes the sum of the squares of the errors.
  댓글 수: 1
John D'Errico
John D'Errico 2017년 5월 9일
Let me give an example. Again, since I have no access to your variables, I'll make some up.
a = rand(4,5);
e = rand(4,5);
Apinv = a*pinv(e);
a
a =
0.029258 0.40809 0.10367 0.66646 0.63295
0.70231 0.24895 0.53556 0.84774 0.71043
0.0076356 0.65246 0.16487 0.76266 0.68866
0.61092 0.32028 0.88344 0.80701 0.32095
A*e
ans =
0.075545 0.6519 0.095332 0.52852 0.42334
0.7681 0.59546 0.52371 0.65171 0.41252
0.04162 0.83147 0.15875 0.66139 0.53476
0.64048 0.476 0.87811 0.71892 0.18707
The two are reasonably close, but not identical. Is it exact? Of course not! I said it cannot be so in general.
apinverr = norm(A*e - a)
apinverr =
0.7031
But perturb A by a wee bit, and the error will be randomly worse.
norm((A+randn(size(A))/100)*e - a)
ans =
0.70449

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Linear Algebra에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by