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!

Least squares fit to a straight line?

  1. Jan 30, 2010 #1
    I was wondering if someone could explain how to compute the Least squares fit to a straight line
     
  2. jcsd
  3. Jan 30, 2010 #2

    ehild

    User Avatar
    Homework Helper
    Gold Member

    You have N experimental points (xi,yi) and you want to fit a straight line y=ax+b across them so that the mean value of the square of the deviations y(xi)-yi is minimum with respect to the parameters a and b
    .
    [tex]S=\sum_1^N{(ax_i+b-y_i)^2} = minimum[/tex]

    For that, the partial derivatives of S have to be zero. This condition yields two equations for a and b.

    [tex] \partial S /\partial a=\sum_1^N{2(ax_i+b-y_i)x_i}=0[/tex]
    [tex] \partial S /\partial b=\sum_1^N{2(ax_i+b-y_i)}=0[/tex]

    Rearranging the equations:

    [tex] a\sum_1^N{x_i^2}+b\sum_1^N{x_i}=\sum_1^N{x_i y_i}[/tex]

    [tex] a\sum_1^N{x_i}+N b=\sum_1^N{y_i}[/tex]

    Solve for a and b.

    ehild
     
  4. Jan 30, 2010 #3
    i have solved it and got this

    y = 46.3x+(-61.8)

    my question is now, i plotted my points on a table on paper but how do i make the straight line?
     
  5. Jan 31, 2010 #4

    ehild

    User Avatar
    Homework Helper
    Gold Member

    Just calculate two points of your equation, put them onto the plot and connect them with a straight line :)

    ehild
     
  6. Jan 31, 2010 #5
    how didnt i think of that duhhh lol, one more question now how do i calculate g from the slope?
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Least squares fit to a straight line?
Loading...