# forum.alglib.net

ALGLIB forum
 It is currently Mon Sep 16, 2024 7:04 pm

 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.

 Page 1 of 1 [ 7 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: Linear Fitting: More equations, greater error ?Posted: Wed Feb 23, 2011 3:58 pm

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

 Post subject: Re: Linear Fitting: More equations, greater error ?Posted: Wed Feb 23, 2011 4:50 pm

Joined: Fri May 07, 2010 7:06 am
Posts: 922
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

 Post subject: Re: Linear Fitting: More equations, greater error ?Posted: Wed Feb 23, 2011 8:18 pm

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

Top

 Post subject: Re: Linear Fitting: More equations, greater error ?Posted: Thu Feb 24, 2011 11:08 am

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

 Post subject: Re: Linear Fitting: More equations, greater error ?Posted: Fri Feb 25, 2011 4:11 pm

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

 Post subject: Re: Linear Fitting: More equations, greater error ?Posted: Fri Feb 25, 2011 6:59 pm

Joined: Fri May 07, 2010 7:06 am
Posts: 922
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

 Post subject: Re: Linear Fitting: More equations, greater error ?Posted: Sat Feb 26, 2011 8:35 pm

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

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 7 posts ]

 All times are UTC

#### Who is online

Users browsing this forum: Bing [Bot] and 5 guests

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

Search for: