Fitting a function: constraining a parameter to be 0 or 1?

5 vues (au cours des 30 derniers jours)
Greg
Greg le 12 Déc 2014
Réponse apportée : Matt J le 12 Déc 2014
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.

Réponses (1)

Matt J
Matt J le 12 Déc 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.

Catégories

En savoir plus sur Least Squares dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by