forum.alglib.net

ALGLIB forum
It is currently Mon Dec 23, 2024 12:48 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  [ 2 posts ] 
Author Message
 Post subject: setting constraints in polynomial fit
PostPosted: Mon Aug 13, 2012 6:36 pm 
Offline

Joined: Mon Aug 13, 2012 6:22 pm
Posts: 3
I'm sure there's a simple answer to this, but I'm stuck. I have a small set of that data that I am doing a polynomial fit on (data below). When I run (m=4):

Code:
alglib.polynomialfit(x, y, m, out info, out p, out rep);
alglib.polynomialbar2pow(p, out coeffs);


I get the results I am anticipating: {25.426138,0.092663,-0.000658,0.000001}

I would like to be able to weight this data, but when I run the polynomialfitwc function, I get different results. I set all w=1 (an array of equal length to x where all elements =1), and:

Code:
double[] xc = new double[] { 0 }; //constraints = 0
double[] yc = new double[] { 0 };
int[] dc = new int[] { 0 };


These settings give me the following coefficients: {0.000000,1.116681,-0.011579,0.000035}

What am I doing wrong? I'd like to set up the wc function so it returns that same as polynomialfit() if the weights are 1.

Thanks in advance. This package is really impressive.

Data:

X_1 Y_1
6 26
28 27.5
50 28.4
69 29.35
93 29.4
116 29.35
137 29.15
158 28.82
180 28.5


Top
 Profile  
 
 Post subject: Re: setting constraints in polynomial fit
PostPosted: Fri Aug 17, 2012 2:48 pm 
Offline

Joined: Mon Aug 13, 2012 6:22 pm
Posts: 3
Came back to this and realized this is (as I figured) a simple syntax error. I'll post here in case this saves anybody some time in the future:

empty constraints should be set as:
Code:
            double[] xc = new double[0]; //constraints = 0
            double[] yc = new double[0];
            int[] dc = new int[0];


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 19 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:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group