Fitting a function: constraining a parameter to be 0 or 1?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have two variables of the same length, e.g. x and y. I want to find the parameters for function f such that y = f(x). Functions like lsqcurvefit let me bound the parameters, but is there any way to constrain a parameter to be an integer?
Specifically I have a parameter that I want to constrain to be either 0 or 1. Is there a way to do this? Any help would be lovely.
0 Kommentare
Antworten (1)
Matt J
am 12 Dez. 2014
Probably not applicable to (or too complicated for) this problem, but if f(x) has a linear dependence on the unknowns,
y=p1*f1(x)+p2*f2(x)+...+pn*fn(x)
where p1...pn are the unknown parameters, some of which are integers, then instead of doing a least squares fit, you can do a max-norm fit
min r
subject to
-r<=y-( p1*f1(x)+p2*f2(x)+...+pn*fn(x) )<=r
which is a mixed integer linear program in the variables [r,p1,...,p3] and can be solved with intlinprog . An L1-norm fit can be done in a similar way.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Least Squares finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!