Re: Least squares fit for two parameter matrices?



In article <ef5b43c.-1@xxxxxxxxxxxxxxxxxxxxxxx>, "Urban Simoncic"
<urban.simoncic@xxxxxxxxx> wrote:

Hi,

I have m×n matrix of measurements called M, which is supposed to be
equal to product of two matrix of unknown parameter; first matrix is
called C and is m×2 and second is I and is 2×n.
Basically I have system M=C*I, which is nonlinear system of m*n
equations and 2(m+n) unknowns. Since m and n are about 100, I have
much more equations than unknowns and I would like to determine
matrices C and I by a kind of least squares fit.

Does exist any algorithm to do that? Is possible to do that in
Matlab?

Thanks in advance for any help.

Urban
----------------------
I have found a way to solve your problem with C only an m by 1 column
vector and I a 1 by n row vector, if that is of any interest to you,
Urban. Unfortunately, I haven't yet found a solution to the problem you
posed with two columns and two rows, respectively. Perhaps someone else
in this group knows how to do this.

For the m by 1 and 1 by n vectors, let M be the m by n matrix, and we
wish to find C and I such that C*I is the best approximation to M in the
least squares sense. If we take the partial derivatives of phi =
sum(sum((C*I-M).^2) with respect to each element of I and set each one to
zero, we obtain

I = (C.'*M)/sum(C.^2).

Similarly, setting each of the partial derivatives of phi with respect to
elements of C to zero yields

C = (M*I.')/sum(I.^2). Substituting the I from the first equation into
the second one yields

C = 1/sum(C.^2)/sum(I.^2)*(M*M.')*C.

This last equation shows that C must be proportional to one of the
eigenvectors of A = M*M.', so this leads to the following matlab
procedure:

A = M*M.';
[U,S,V] = svd(A);
C = V(:,1); % The largest eigenvalue gives the best fit
I = C.'*M; % Take advantage of the fact that C is a unit vector

It can be shown that the mean square error is given by:

1/(m*n)*(sum(sum(M.^2))-S(1,1)),

so it is least with the largest eigenvalue, S(1,1).

Note that this solution is not unique. C can be multiplied by any
desired scalar factor provided that I is divided by the same factor, and
the approximation will be equally good.

Roger Stafford
.



Relevant Pages

  • Re: Exact or Least-Squares Solution 5 Equations
    ... >> on the right hand side we have a linear part in the three unknowns. ... >> identical to that of the squared system (the optimal sum of squares will not be ... solve the top 3 simultaneous linear equations for B, C, D ...
    (sci.math.num-analysis)
  • Re: Exact or Least-Squares Solution 5 Equations
    ... (Peter Spellucci) ... >I've tried a number of techniques to solve 5 equations in 5 unknowns ... this because the least squares solution of the original system will not be ... solve the top 3 simultaneous linear equations for B, C, D ...
    (sci.math.num-analysis)
  • Re: Exact or Least-Squares Solution 5 Equations
    ... >I've tried a number of techniques to solve 5 equations in 5 unknowns ... this because the least squares solution of the original system will not be ... solve the top 3 simultaneous linear equations for B, C, D ...
    (sci.math.num-analysis)
  • Re: Need help with method of least squares
    ... Linear least squares require that you take the square of difference ... But in my case my unknowns are partial ... problem and can be solved uniquely if U has full row rank. ...
    (sci.math)
  • Least squares fit for two parameter matrices?
    ... equal to product of two matrix of unknown parameter; first matrix is ... which is nonlinear system of m*n ... equations and 2unknowns. ...
    (comp.soft-sys.matlab)