Need help with polynomial fitting

  • Context: Undergrad 
  • Thread starter Thread starter Brad_Ad23
  • Start date Start date
  • Tags Tags
    Fitting Polynomial
Click For Summary
SUMMARY

The discussion centers on the challenge of obtaining a polynomial that minimizes the distance between two existing polynomials fitted to different data sets. Participants suggest averaging the two polynomials as a potential solution, represented as r(x) = [p(x) + q(x)]/2. However, they clarify that this average polynomial does not necessarily minimize the distance between all points. Instead, a more effective approach involves treating the two data sets as a single entity and applying a least squares fit to derive a single polynomial that minimizes the overall error across both sets.

PREREQUISITES
  • Understanding of polynomial fitting techniques
  • Familiarity with least squares regression methods
  • Knowledge of numerical optimization concepts
  • Experience with software tools like Excel or Mathematica for data analysis
NEXT STEPS
  • Research polynomial regression techniques in Python using libraries like NumPy or SciPy
  • Explore least squares fitting methods and their applications in data analysis
  • Learn about numerical optimization methods, including Lagrange multipliers
  • Investigate how to implement polynomial fitting in Excel and Mathematica
USEFUL FOR

Data scientists, statisticians, and anyone involved in data modeling and analysis who seeks to understand polynomial fitting and optimization techniques.

Brad_Ad23
Messages
497
Reaction score
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
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...
 
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.
 
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. :

minimize {(y1_n - y1(x1_n))^2 + (y2_n - y2(x2_n))^2 + (y1_n - y2_n)^2}

P.S : some context would help...what do you want to achieve ?
 
Last edited:
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).
 
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.
 
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.
 
Correct, I am indeed trying to forecast. And ok, that does make sense, about the average polynomial being the correct one.
 
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.
 

Similar threads

  • · Replies 16 ·
Replies
16
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 13 ·
Replies
13
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 23 ·
Replies
23
Views
4K
  • · Replies 28 ·
Replies
28
Views
3K
  • · Replies 7 ·
Replies
7
Views
2K