How to find coefficients in linear combination of functions
3 views (last 30 days)
Show older comments
Hello
I have faced a problem: I have three function's made of a experimental data. Say f1(P), f2(P), f3(P) and they all depend on P. f1(P), f2(P) and f3(P) are in vector form, ie. : f1=[f1value1 f1value2 ... f1valuen] etc. and P=[p1 p2 ... pn]. Where f1valuen, f2valuen, f3valuen and pn are finite, discrete values.
Finally i have an equation like F(P) = ∝1*f1(P)+∝2*f1(P)+∝3*f3(P).
My question is: How to find ∝1, ∝2 and ∝3 ?
I know additionally that ∝1+∝2+∝3=1 and ∝1<∝2 and ∝3<∝2
0 Comments
Answers (1)
Matt J
on 17 Sep 2017
Edited: Matt J
on 17 Sep 2017
It's a linear least squares problem with linear constraints. You can use LSQLIN, if you have Optimization Toolbox.
x = lsqlin(C,d,A,b,Aeq,beq,lb,ub)
The columns of the matrix C will come from your f_n(P) data and similary d will be a column vector composed of the F(P) samples.
6 Comments
Walter Roberson
on 24 Oct 2017
Given the particular values f1P, f2P, f3P, you can construct
residual = @(alpha) sum( (alpha(1)*f1P + alpha(2)*f2P + alpha(3)*f3P - fP).^2 )
and then do an optimization to try to minimize residual. This is a form of least squares fitting, and it should give the same as
alpha = [f1P(:), f2P(:), f3P(:)] \ fp(:);
Matt J
on 25 Oct 2017
Although, to do least squares fitting subject to constraints on ∝_i, as in the original post, you will need lsqlin.
See Also
Categories
Find more on Linear Least Squares 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!