Fitting a function: constraining a parameter to be 0 or 1?
조회 수: 3 (최근 30일)
이전 댓글 표시
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
답변 (1개)
Matt J
2014년 12월 12일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Least Squares에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!