Need help with polynomial fitting

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

Discussion Overview

The discussion revolves around the challenge of obtaining a polynomial that minimizes the distance between points on two existing polynomials fitted to different sets of data. Participants explore various approaches to this problem, including averaging techniques and considerations for fitting methods.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant inquires about a polynomial that minimizes the distance between points on two existing polynomials.
  • Another suggests using the average of the two polynomials as a potential solution, though this is challenged as merely an average rather than a minimizing polynomial.
  • A different participant compares the situation to linear regression, suggesting that a polynomial could be fitted to minimize distances to both sets of points.
  • Concerns are raised about the phrasing of the original question, with suggestions that a clearer context would help in understanding the problem.
  • One participant proposes a mathematical formulation for minimizing the sum of errors and distances between the two polynomials.
  • Another participant provides numerical examples to clarify the problem, expressing difficulty in implementing a solution using software tools like Excel or Mathematica.
  • There is a discussion about the concept of "minimum distance," with one participant suggesting that averaging the y-values at corresponding x-values could be a reasonable approach.
  • Another participant asserts that the average polynomial indeed minimizes the sum of squares of distances, prompting further questions about the intent behind the original inquiry.
  • A new participant introduces a related question about finding a transformation to align two bidimensional curves, which raises additional questions about the definitions and methods involved.
  • One participant seeks clarification on the mathematical formulation of the new question regarding bidimensional curves and transformations.

Areas of Agreement / Disagreement

Participants express differing views on the appropriateness of using an average polynomial to minimize distances, with some supporting this approach and others questioning its validity. The discussion remains unresolved regarding the best method to achieve the desired polynomial fitting.

Contextual Notes

There are limitations in the clarity of the original question, particularly regarding the definitions of distance and the role of the third polynomial. Additionally, the discussion includes unresolved mathematical steps and assumptions about the data sets.

Who May Find This Useful

This discussion may be of interest to those involved in data fitting, polynomial regression, and mathematical modeling, particularly in contexts where multiple data sets are analyzed simultaneously.

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 7 ·
Replies
7
Views
2K
  • · Replies 16 ·
Replies
16
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 3 ·
Replies
3
Views
1K
  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 13 ·
Replies
13
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 23 ·
Replies
23
Views
4K