Need help with polynomial fitting

In summary, you can try the polynomial r(x) = [p(x) + q(x)]/2. Just a suggestion...That would just be an average polynomial. I don't know if that would necessarily be a polynomial that minimizes the distance between all points. I'm thinking along the lines of like the best fit line in linear regression. It will come close to some points but far from others, but it is is the closest it can be to all points.
  • #1
Brad_Ad23
502
1
I have two polynomials fit to two different sets of data points. What I need to know is if there is a way to obtain a polynomial such that it will minimize the distance between all the points on both the other polynomials?
 
Physics news on Phys.org
  • #2
Brad_Ad23 said:
I have two polynomials fit to two different sets of data points. What I need to know is if there is a way to obtain a polynomial such that it will minimize the distance between all the points on both the other polynomials?
If you have polynomials p(x) and q(x), maybe try the polynomial r(x) = [p(x) + q(x)]/2. Just a suggestion...
 
  • #3
That would just be an average polynomial. I don't know if that would necessarily be a polynomial that minimizes the distance between all points. I'm thinking along the lines of like the best fit line in linear regression. It will come close to some points but far from others, but it is is the closest it can be to all points. Same here with my two polynomials.
 
  • #4
Your question is poorly phrased.

If you have two fixed polynomials that you have fit to the data sets, then the distances between their points is fixed. Then I don't see what the role of the third polynomial is.

If there is no third polynomial and you just want to fit 2 polynoms to the data sets such that the distance between the curves is minimized, then do you care about the individual errors in each of the fits ? If you don't care about the errors, then your solution is a single polynomial fitting both data sets - i.e treat them as a single data set, and do a least squares fit.

If you "also" care about the individual errors, then you might perhaps want to minimize something like the sum of the errors and the distance between curves, i.e. :

[tex] minimize {(y1_n - y1(x1_n))^2 + (y2_n - y2(x2_n))^2 + (y1_n - y2_n)^2} [/tex]

P.S : some context would help...what do you want to achieve ?
 
Last edited:
  • #5
Ok, sorry about the phrasing. I'll use some numerical examples.

Say I have a set of numbers {2,6,8,5,7}. The 2 occurs at x=1 and likewise onwards (i.e. x = 5, y =7). From these points, assume I have a polynomial that fits the distribution. Then, let us say I have another set of numbers {1,4.6,7,9,5} again the first number occurs at x=1 and so on. Then I obtain a polynomial of the same degree that fits the distribution as well.

Now, I realize that I could treat this all as a single data set, so that at x = 1 I have a y value of 2 and 1 and so on. Unfortunately, I can't figure out how to do this in Excel or Mathematica. Alternatively, I also have both equations for the polynomial. What I need is a third polynomial such that for all the x values from 1 to 5, the 3rd polynomial has its y values such that they are a minimum distance away from the other two data points. I know that basically this curve is going to be inbetween the other two, but I just don't know how to generate it. Or how to set up a program to allow for relations instead of functions (that is 2 y values for a single series).
 
  • #6
you still arent' being specific enough: what do you mean by minimum distance away? the obvious and, as far as it is stated, reasonable solution is a polynomial passing through the points {1.5, 5.3, 7.5,7,6} in the example given, by averaging the y values.
 
  • #7
If you are wondering whether the "average polynomial" is really the one that minimizes the sum of squares of distances...wonder no more. It IS the one. Think about what happens to this sum of squares as a point moves away from the midpoint between 2 y's. You'll see that the sum only gets bigger. You can check this using lagrange multipliers and minimizing - if you want.

It's still not clear what you are trying to do. Are you attempting some form of forecasting ? This would explain why you have more than one y for the same x.
 
  • #8
Correct, I am indeed trying to forecast. And ok, that does make sense, about the average polynomial being the correct one.
 
  • #9
Hello,
I'm new to the forum. This is the more interesting forum I ever found!

I have a similar question: given two bidimensional curves in the space, find the Rototraslation that bring one curve as closest as possible (following a non specified notion of distance) to the other.

Anybody has an answer?

thanks,
 
  • #10
no answer but plenty of questions:

what on Earth is a bidmensional curve, what is 'the' space, what is a rototranslation exactly, and how do you expect someone to minimize an un specified quantity?
 
  • #11
Do you have z1(x,y) and z2(x,y) ?

And do you want to find (x0,y0), phi, that minimizes

SUM[z1(x_i,y_i) - z2(x0 + x_i cos(phi) +y_i sin(phi), y0 + y_i cos(phi - x_i sin(phi) ) ] ?

This is my best guess from the info provided.
 

FAQ: Need help with polynomial fitting

What is polynomial fitting?

Polynomial fitting is a mathematical process used to find a curve that best fits a given set of data points. It involves finding the coefficients of a polynomial equation that closely matches the data points.

Why is polynomial fitting useful?

Polynomial fitting is useful because it allows us to model and predict the behavior of complex data sets. It can also help us identify trends and patterns in the data, and make more accurate predictions based on the fitted curve.

What are the steps involved in polynomial fitting?

The steps involved in polynomial fitting include selecting an appropriate degree for the polynomial, finding the coefficients using a least squares method, and evaluating the fitted curve for accuracy and reliability.

What are some common challenges in polynomial fitting?

Some common challenges in polynomial fitting include overfitting, where the fitted curve matches the data points too closely and may not accurately represent the underlying trends, and underfitting, where the fitted curve is too simple and does not capture enough of the data's complexity.

How can I improve the accuracy of a polynomial fit?

To improve the accuracy of a polynomial fit, you can try increasing the degree of the polynomial or using a different fitting method. It is also important to carefully evaluate the fitted curve and make adjustments as needed. Additionally, having a larger and more diverse data set can also help improve the accuracy of the fit.

Similar threads

Replies
16
Views
2K
Replies
2
Views
1K
Replies
4
Views
1K
Replies
7
Views
2K
Replies
28
Views
2K
Back
Top