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!

Confused on Linear Least Square Fits very basic.

  1. Mar 29, 2010 #1
    Quite confused. I've read the book/online definitions yet I suppose I may need a simpler explanation.

    Lets say I have a table of x y values.

    x 1 2 3 4 5
    y 6 7 8 9 10

    how would I carry out the linear least squares fit of the data to determine the slope and y-intercept?
     
  2. jcsd
  3. Mar 29, 2010 #2

    jtbell

    User Avatar

    Staff: Mentor

    How about you tell us a definition that you've seen (or give us a link to it), and tell us where you get stuck in trying to apply it?
     
  4. Mar 30, 2010 #3

    HallsofIvy

    User Avatar
    Staff Emeritus
    Science Advisor

    As jtbell says, there are a number of equivalent ways to do that. Not necessarily the simplest, but the most direct is this: Let the line be y= mx+ b where "m" is the slope and "b" is the y-intercept. For x= 1, the "calculated value" would be y= m+ h while the true value is 6. The "square error" is [itex](m+ b- 6)^2[/itex]. Similarly, for x= 2 the "calculated value" would be y= 2m+ b while the true value is 7. The "square error" is [itex](2m+b- 7)^2[/itex]. Repeating that for all given values, the "total square error" would be [itex](m+ b- 6)^2+ (2m+ b- 7)^2+ (3m+ b- 8)^2+ (4m+ b- 9)^2+ (5m+ b- 10)^2[/math]. To minimize that, take the partial derivatives with respect to m and b and set them equal to 0.

    Of course, for this particular example, it is obvious that the line y= x+ 5 goes exactly through every point so that is what you would get.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook