[Scilab-users] {EXT} Re: horner test
Rafael Guerra
jrafaelbguerra at hotmail.com
Fri Oct 28 11:23:47 CEST 2016
Hi Christophe,
The linear regression method and functions that you propose below do fit the data much better than the optim solution.
Thanks and regards,
Rafael
-----Original Message-----
From: users [mailto:users-bounces at lists.scilab.org] On Behalf Of Dang Ngoc Chan, Christophe
Sent: Friday, October 28, 2016 10:04 AM
To: Users mailing list for Scilab <users at lists.scilab.org>
Subject: Re: [Scilab-users] {EXT} Re: horner test
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.
_______________________________________________
users mailing list
users at lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users
More information about the users
mailing list