Ramblingsthe_s3ntinelFebruary 22 2010, 07:10:50 UTC
I don't think the term 'fit' necessarily connotes 'getting a line to go through the dots exactly'. In fact, 'regression' is basically a synonym for model-fitting. Also, while it is certainly possible to find a 9th-order polynomial that will 'join up the dots' this is something you'd rarely want to do, except perhaps as an exercise in linear algebra.
Typically in statistics, one wants to find a model with as few parameters as possible, but which explains most of the variability in the data.
The way to do a regression (to a cubic polynomial) is not to find polynomial that will go exactly through four points and then just 'see what happens' with the rest. I don't really know what your project wants you to do, so don't assume that the following is necessarily what they're after, but for your edification, here is a description of how to do a 'least squares' regression to a cubic:
Suppose the model you're trying to fit is as follows: y = α3x3 + α2x2 + α1x + α0 + (error term). Let α denote the column vector (α0 α1 α2 α3)T. First you
( ... )
Re: RamblingschreeskoFebruary 22 2010, 08:31:58 UTC
Thank you for the explanation. This is something that I last studied years ago (and even then I didn't have the best grasp of it) so I appreciate the clarification.
For my specific problem, I've been given a set of data points and told to create an equation that fits the graph. I decided to go the tedious linear algebra route because I wasn't sure what order polynomial my equation would have, and I thought it would be the most thorough method to ensure I didn't miss anything (and I also couldn't think of another way to do it). Based on your explanation, though, it seems that another way would be to go through and do a least squares regression to a cubic, quartic, etc. until I find the best fit.
If you want to fit nine points exactly on a polynomial graph, then you only need a polynomial of degree 8. (You can fit two points on a line, three points on a parabola, and so on: n+1 points on a polynomial of degree n.) But it would probably be a better strategy to look for a polynomial of much lower degree (3 or 4, say), and see how good a fit it will give you, using a least-squares approximation.
There is a somewhat easier way of constructing the degree 8 polynomial which goes through all those points called the Lagrange interpolating formula (I think).
Call your 9 points (xi, yi)
First, define 9 polynomials gj(x) for j = 1..9 by
gj(x) = (x-x1)(x-x2)...(x-x9) where you skip (x-xj) in this product.
Then define f(x) = the sum from j = 1 to 9 of yj g(x)/ g(xj).
I claim that f(x) is the unique degree 8 polynomial going through all 9 points. To see this, just plug stuff in.
For example, say you want to evaluate f(x1). The point is that when you plug in x1 into each of g2(x),...,g9(x) you get 0 by definition. Hence f(x1) = y1 g(x1)/g(x1) = y1 as claimed.
Comments 6
Typically in statistics, one wants to find a model with as few parameters as possible, but which explains most of the variability in the data.
The way to do a regression (to a cubic polynomial) is not to find polynomial that will go exactly through four points and then just 'see what happens' with the rest. I don't really know what your project wants you to do, so don't assume that the following is necessarily what they're after, but for your edification, here is a description of how to do a 'least squares' regression to a cubic:
Suppose the model you're trying to fit is as follows: y = α3x3 + α2x2 + α1x + α0 + (error term). Let α denote the column vector (α0 α1 α2 α3)T. First you ( ... )
Reply
For my specific problem, I've been given a set of data points and told to create an equation that fits the graph. I decided to go the tedious linear algebra route because I wasn't sure what order polynomial my equation would have, and I thought it would be the most thorough method to ensure I didn't miss anything (and I also couldn't think of another way to do it). Based on your explanation, though, it seems that another way would be to go through and do a least squares regression to a cubic, quartic, etc. until I find the best fit.
Reply
Reply
Reply
Call your 9 points (xi, yi)
First, define 9 polynomials gj(x) for j = 1..9 by
gj(x) = (x-x1)(x-x2)...(x-x9) where you skip (x-xj) in this product.
Then define f(x) = the sum from j = 1 to 9 of yj g(x)/ g(xj).
I claim that f(x) is the unique degree 8 polynomial going through all 9 points. To see this, just plug stuff in.
For example, say you want to evaluate f(x1). The point is that when you plug in x1 into each of g2(x),...,g9(x) you get 0 by definition. Hence f(x1) = y1 g(x1)/g(x1) = y1 as claimed.
Reply
Reply
Leave a comment