Optimization of a sum with unknown coefficients
10 views (last 30 days)
Show older comments
I'm working on some coding and I'm having an issue with mimimizing an equation. Essientally, I have a sum that has a different coeffiecent for every term and I'm trying find the coefficent. Mathematically it looks like:
A*B = sum(C*D)
I know A,B, and D. A and B are both scalar. C and D I have reshaped (using reshape) from a square matrix to a vector. So the right hand sid eof the equation is essentially C(1)*D(1) + C(2)*D(2) + ... + C(N)*D(N).
I've been trying to use fminsearch to find the values but I keep running into issues. The code I created looks like:
fn = @(C) (A*B - sum(C*D))^2
opt = fminsearch(fn, 1)
Any thoughts or suggestions would be appreciated.
0 Comments
Answers (2)
Roger Stafford
on 12 Mar 2014
If the values of the D elements are non-zero, you have a very undetermined system for which there are infinitely many values of the C coefficients that will yield a minimum value of zero to 'fn'. It's no wonder you "keep running into issues". The 'fminsearch' function doesn't understand which of this infinitude you wish to choose.
For example, suppose N = 3 and the C coefficients are x, y, and z cartesian coordinates of points in 3D space. The A*B and three D quantities represent a 2D plane somewhere in that space. The 'fn' quantity would be the square of the orthogonal distance from a point (x,y,z) in space to that plane. You would be asking 'fminsearch' which is the point that is closest to the plane. Unfortunately there are infinitely many points that are right on the plane with zero distance and 'fminsearch' is left not knowing which one to choose.
I have the feeling you have some other conditions you wish also to place on your coefficients that you are not telling us about.
2 Comments
Matt J
on 12 Mar 2014
Edited: Matt J
on 12 Mar 2014
A*B = sum(C*D)
This is the equation for a (hyper)plane. Any one of infinite C lying on the hyperplane is a solution of the equation, so no wonder you cannot solve it uniquely.
However, the minimum norm solution is given by
C = pinv(D(:).')*(A*B)
0 Comments
See Also
Categories
Find more on Get Started with Optimization Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!