forum.alglib.net

ALGLIB forum
It is currently Sun Dec 22, 2024 9:06 am

All times are UTC


Forum rules


1. This forum can be used for discussion of both ALGLIB-related and general numerical analysis questions
2. This forum is English-only - postings in other languages will be removed.



Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Linear Fitting: More equations, greater error ?
PostPosted: Wed Feb 23, 2011 3:58 pm 
Offline

Joined: Wed Feb 23, 2011 3:50 pm
Posts: 4
Dear Sergey,

first I want to take the opportunity an gratulate you on ALGLIB, a great library, extremely clean coding style, very efficient.
Great work, a good programmer :)

I have only one simple question: when using linear interpolation (it is in fact polynomial regression, most of the values in the function
matrix are powers of >some x<), I encounter the issue that when increasing the number of equations (degrees of freedom in my model) over
a certain limit, often about 5 * 20 equations (means 5 sub-matrices with x^0 - x^20), the overall error starts to increase again.

Is it likely to be related to floating point / IEEE754 issues? I would guess so.

Best Regards :)


Top
 Profile  
 
 Post subject: Re: Linear Fitting: More equations, greater error ?
PostPosted: Wed Feb 23, 2011 4:50 pm 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 927
Almost surely, it is floating point issue. Polynomial basis is ill-conditioned, and having x^20 as basis function will give you very badly conditioned matrix. You can check fitting report, in particular - rep.taskrcond variable. If it is lower than 10^(-10), than you definitely have problems with condition number.

I recommend you to switch to better basis - for example, to replace x^i with centered Chebyshev polynomials.


Top
 Profile  
 
 Post subject: Re: Linear Fitting: More equations, greater error ?
PostPosted: Wed Feb 23, 2011 8:18 pm 
Offline

Joined: Wed Feb 23, 2011 3:50 pm
Posts: 4
Thank You for your time!


Top
 Profile  
 
 Post subject: Re: Linear Fitting: More equations, greater error ?
PostPosted: Thu Feb 24, 2011 11:08 am 
Offline

Joined: Sun May 16, 2010 11:42 pm
Posts: 63
The polyfit function seems to give much better results for fitting high order polynomials than the least squares functions.

See an Excel implementation and examples here:

http://newtonexcelbach.wordpress.com/20 ... functions/

_________________
Doug Jenkins
http://newtonexcelbach.wordpress.com/


Top
 Profile  
 
 Post subject: Re: Linear Fitting: More equations, greater error ?
PostPosted: Fri Feb 25, 2011 4:11 pm 
Offline

Joined: Wed Feb 23, 2011 3:50 pm
Posts: 4
Doug, I'm aware. The polynomial fitting uses a barycentric method. However, not all equations in my model are polynomials.


Top
 Profile  
 
 Post subject: Re: Linear Fitting: More equations, greater error ?
PostPosted: Fri Feb 25, 2011 6:59 pm 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 927
Quote:
The polynomial fitting uses a barycentric method.

Polynomial fitting uses Chebyshev basis internally, it just converts results into barycentric form before output.

Quote:
However, not all equations in my model are polynomials.

I've recommended you to use Chebyshev polynomials as basis because you can use it with non-polynomial basis functions.


Top
 Profile  
 
 Post subject: Re: Linear Fitting: More equations, greater error ?
PostPosted: Sat Feb 26, 2011 8:35 pm 
Offline

Joined: Wed Feb 23, 2011 3:50 pm
Posts: 4
Thanks again, I have looked at the matrix condition and I'm using now Chebychev Polynomials with -1 <= x <= +1


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 39 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group