[Scilab-users] errors (uncertainties) in non-linear least-squares fitting parameters

CRETE Denis denis.crete at thalesgroup.com
Tue Aug 25 16:38:21 CEST 2020


Hello,
If the fixed point has to be optimized as well, it is possible to keep a linear treatment, although the solution that I have found is tedious:
First, notice that because of the fixed point and the set of xk is the same for the 3 lines, all Y coordinates are proportional, I mean

-          y2(xk)=P2/P1*y1(xk)

-          y3(xk)=P3/P1*y1(xk)
It is probably easy to fit the datasets y2 and y3 as a function of y1 to find r=P2/P1 and s=P3/P1. It might even be possible to use r=sum(y2)/sum(y1) and s= sum(y3)/sum(y1)... but the exact solution of the least square method is r=sum(y2.*y1)/sum(y1.*y1), s= sum(y3.*y1)/sum(y1.*y1).
Then the full dataset of the 3 functions y1, y2/r and y3/s can be adjusted to the same function p1*x+A (e.g. using reglin)
However, I did not write the code, yet... There might exist a more elegant solution...
I understand it is not in the focus of the initial question, but it may help anyway.

Denis
NB: a more compact algorithm is to fit for i=1...3,  yi/sum(yi.*y1)= f(x)

De : users <users-bounces at lists.scilab.org> De la part de Rafael Guerra
Envoyé : mardi 25 août 2020 01:47
À : Heinz Nabielek <heinznabielek at me.com>; Users mailing list for Scilab <users at lists.scilab.org>
Objet : Re: [Scilab-users] errors (uncertainties) in non-linear least-squares fitting parameters

In that case, the code can be simplified using backslash left matrix division:

// Fixed point (-4,0) solution:
a = (MW+4)\Y;
b = a*4;
GG= a'.*.xx' + repmat(b',1,size(xx,1));
plot(xx,GG','LineWidth',1);

Regards,
Rafael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20200825/95ccaf9b/attachment.htm>


More information about the users mailing list