[Scilab-users] {EXT} Re: horner test

Dang Ngoc Chan, Christophe Christophe.Dang at sidel.com
Fri Oct 28 10:03:41 CEST 2016


Hello,

> De : users [mailto:users-bounces at lists.scilab.org] De la part de Rafael Guerra
> Envoyé : jeudi 27 octobre 2016 20:23
>
> (note: votre message n'a pas été publié)
> […]
> function f = fmodel(a,x)
>     f = exp(a(1) + a(2)*x + a(3)*x.^a(4));
>  endfunction
>
> function f = costfun(a,x,y)
 >  f = norm(y - fmodel(a,x));
> endfunction
>
> a0 = [0;0;0;0];
> [f,aop]= optim(list(NDcost,costfun,x,y),a0);

As I didn't know why the message was not published, I answered directly to the sender (hope he/she got it).
I personally recommended to first look for a power function

A = [log(x), ones(x)]\log(y)

which gives a satisfactory result in itself.

plot(x, exp(A(2))*x^A(1));
plot(x, y, "o");

Then we see that the power is close to -3, we can also try a 3rd degree 1/x polynomial

invx = x.^-1;
X = [invx.^3, invx.^2, invx, ones(x)];
B = X\y;

plot(x, X*B);
plot(x, y, "o");

All this is less straightforward and automatized as your method,
but maybe more stable (and faster ?) as it only uses linear regression.

regards

--
Christophe Dang Ngoc Chan
Mechanical calculation engineer
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error), please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.


More information about the users mailing list