How can I solve the least square minimization Ax=b when b is unknown?
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Valentina
il 28 Mar 2015
Modificato: John D'Errico
il 29 Mar 2015
Hi all,
I'm new in the forum. I've been thinking to this problem for a long time, so any suggestion would be appreciated. I've the following problem:
I have this equation
E p = d, where
E = (x1, y1, z1;
x2, y2, z2;
x3, y3, z3;
x4, y4, z4)
p = (a; b; c)
d = (d; d; d; d)
I want to find p using the least square minimization, but also d is unknown.
Do you have any suggestion?
Thank you
Valentina
1 Commento
Star Strider
il 28 Mar 2015
Modificato: Star Strider
il 28 Mar 2015
Tell us more about what created that problem. Maybe that will suggest a solution.
Risposta accettata
Roger Stafford
il 28 Mar 2015
Modificato: Roger Stafford
il 28 Mar 2015
Whatever the value of d is, the following will give the least squares approximation for E*p-[d;d;d;d] = 0.
x = [x1;x2;x3;x4];
y = [y1;y2;y3;y4];
z = [z1;z2;z3;z4];
A = [sum(x.^2),sum(x.*y),sum(x.*z);
sum(x.*y),sum(y.^2),sum(y.*z);
sum(x.*z),sum(y.*z),sum(z.^2)];
p = d*(A\[sum(x);sum(y);sum(z)]);
where p = [a;b;c].
0 Commenti
Più risposte (3)
John D'Errico
il 29 Mar 2015
Modificato: John D'Errico
il 29 Mar 2015
I would point out that the solution is simply a multiple of p1, where p1 is given as the solution of:
E*p1 = ones(4,1)
Think of p1 as the solution for d=1. So solve for p1 as
p1 = E\ones(4,1);
Then despite the fact that you don't know d, the solution is simply
syms d
p = d*p1
Fairly trivial. Of course, that leaves the solution defined in terms of d as a parameter. If you then decided on the value of d, it simply scales p1 to give your answer.
If the goal is to solve for d also, then by moving d into the set of unknowns, now we have:
phat = [a;b;c;d]
Ehat = [x1, y1, z1, -1;
x2, y2, z2, -1;
x3, y3, z3, -1;
x4, y4, z4, -1];
(This is essentially what Matt did, but he missed a sign on d when he moved it to the left hand side.) Now you will be solving the homogeneous problem
Ehat*phat = 0
If the Ehat matrix is of less than full rank (i.e., it is singular), then a non-degenerate solution always exists. We can get the solution from the nullspace of Ehat. Thus the columns of null(Ehat) will yield a pair of vectors that spans the solution set.
For example:
E = [1 2 3;4 5 6;7 8 9;10 11 13]
rank(E)
ans =
3
Ehat = [E,-ones(4,1)]
Ehat =
1 2 3 -1
4 5 6 -1
7 8 9 -1
10 11 13 -1
rank(Ehat)
ans =
3
phat = null(Ehat)
phat =
0.57735
-0.57735
3.2752e-15
-0.57735
In fact, any scalar multiple of this vector is also a solution. So here we have
phat = phat/phat(1)
phat =
1
-1
5.6727e-15
-1
We can now extract a,b,c,d from the above phat vector.
However, if I change E slightly,
E = [1 2 3;4 5 6;7 8 9;10 11 12];
Ehat = [E,-ones(4,1)];
rank(Ehat)
ans =
2
Ehat now has rank 2, so the solution takes on the form of any linear combination of the columns of phat.
phat = null(Ehat)
phat =
-0.50648 -0.27714
0.78363 -0.22934
-0.27714 0.50648
0.22934 0.78363
0 Commenti
Valentina
il 28 Mar 2015
1 Commento
Roger Stafford
il 28 Mar 2015
Valentina, there is absolutely no way of obtaining a least squares solution to your problem without knowing the value of d. What I have given you is simply a formula for computing a least squares solution once you know d.
To ask for a specific solution without knowing d is analogous to asking for the minimum value of a set of numbers without knowing what those numbers are. It is obviously impossible.
Vedere anche
Categorie
Scopri di più su Electrical Block Libraries in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!