1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Homework Help: Approximating/Fitting a function to points

  1. Aug 2, 2009 #1
    Hi, given a function of x, where x increases in uniform increments (ie x goes 1, 2, 3) and y culmalatively increases in the domain x>0, what methods are there to fit a function it to? I want to know method/algorithm that can fit a line/curve to it. So given these points


    I want a Cartesian equation (y= function of x) that can accurately plot a curve through these points - like how a taylor series can be used to approximate functions, but I want to be able to produce a function, or approximate one without. I know that the more disperse the points are from each other the higher the degree of the polynomial (if a polynomial method is used)

    1. The problem statement, all variables and given/known data

    2. Relevant equations

    3. The attempt at a solution
  2. jcsd
  3. Aug 2, 2009 #2
    There are infinite possibilities.

    You can not determine a unique taylor series unless you have infinite days (i.e. know every derivative. However, you can do a polynormial fit for the form:


    For each point, you plug in a value for y and x and you end up with six equations and six unknowns. This is a type of bilinear fit and more generally:


    where the functions [tex]f_1(z)..f(n)[/tex] are independent over the points [tex](x_1,y_1),...,(x_n,y_n)[/tex].

    It is generally not a good idea to fit a lot of points with a higher order polynomial because the fit can be real wavy (noisy). For interpolation, piece wise fits are preferred. Also if you are trying to discover any relationship between the points, it is better to have more data, then unknowns. You won't fit the points exactly but if the data was given at random there would be less variance in your estimates. When you are trying to fit more data then you have unknowns you decide on some optimization criteria like minimum mean squared error.
  4. Aug 2, 2009 #3
    Generally speaking, you try to guess the behavior of the trend from the source. Common choices include exponentials, logarithms, polynomials, and rationals. Trig functions, too. Just play around. Unless you have some clue as to what the function should look like, you can come up with functions that hit all of those points, that hit some of them, and that are pretty close, ad infinitum.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook