Nonlinear least square minimization

조회 수: 5 (최근 30일)
Manish
Manish 2011년 4월 20일
I want to perform a nonlinear least square minimization of the form
Minimize(Sum((Y - F (X ; a, b, c))^2))
Where Y is a vector of response variable; X is a 5 element vector of parameter and a, b and c are vectors of input data. F has the following form:
F = X(5)* Scalar1.* Scalar2.* c;
Scalar 1 is defined as follows.
if X(2)<a<X(1)
Scalar1=((a-X(2))/((X(1)-X(2));
elseif a<=X(2)
Scalar1=0;
elseif a>=X(1)
Scalar1=1;
else
end;
The Scalar2 has a similar definition
if X(4)<b<X(3)
Scalar2 = ((-1)/(X(3)-X(4))).*(b-X(4))+1;
elseif b>=X(3)
Scalar2=0;
elseif b<=X(4)
Scalar2=1;
else
end;
As you can see, I have a function F whose very definition depends on the optimized parameters.
Can someone provide me any lead about where to look for any guidance to solve a problem like this. Any specific keyword/phrase that will help me Google search relevant books, articles will be of great help.

채택된 답변

Steve Grikschat
Steve Grikschat 2011년 4월 20일
Your answer looks ok. lsqnonlin is a good choice. You could also look at lsqcurvefit:
which handles the the responses (Y) and fixed parameters (a,b,c - lsqcurvefit calls this X) automatically. The results would be the same (assuming you've set up lsqnonlin properly) since lsqcurvefit uses the same algorithms as lsqnonlin.
I can't be sure, but there could be problems with the non-smoothness of your function (the piecewise definition). If it works though, that's good.
  댓글 수: 1
Manish
Manish 2011년 4월 20일
Thanks a lot for your response. I have nonoverlapping bounds on different parameters, so i guess non-smoothness is not a problem.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Manish
Manish 2011년 4월 20일
This is how I am defining my objective function
function F = myObjective(X, a, b, c, Y)
index1=a>=X(1);
index2=a<=X(2);
Scalar1=(a-X(2))./(X(1)-X(2));
Scalar1(index1)=1;
Scalar1(index2)=0;
index1=b<=X(4);
index2=b>=X(3);
Scalar2=(X(4)-b)./(X(3)-X(4));
Scalar2(index1)=1;
Scalar2(index2)=0;
F = Y-X(5).* Scalar1.*Scalar2.*c;
I then call 'F' with lsqnonlin.
It gives reasonable answers.
Can someone comment if this is correct.

카테고리

Help CenterFile Exchange에서 Nonlinear Optimization에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by