1. Not finding help here? Sign up for a free 30min 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!

Method of least squares

  1. Feb 26, 2012 #1
    1. The problem statement, all variables and given/known data

    number of years(x): [1,2,3,4,5,6,]
    number of accidents(y): [12,6,5,4,2,2]

    or

    (1,12),(2,6),(3,5),(4,4),(5,2),(6,2)


    2. Relevant equations

    the relation between x and y is on the form: y = a + b(1/x)
    by changing (1/x) to z, the model become linear instead of inverse.
    use this to 'find' a and b

    3. The attempt at a solution

    y = a+b(1/x)
    z = 1/x
    y = a+bz

    matrix A = [(1,1),(1,2),(1,3),(1,4),(1,5),(1,6)]
    vector y = [12,6,5,4,2,2]
    vector x = [a,b]

    finds a solution to ATAx = ATy

    6a + 21b = 31
    21a + 91b = 77

    a = 11.4557
    b = -1.8

    y = 11.4667 - 1.8/x

    but this is wrong the right answer is:
    y = 0.3914 + 11.6945/x

    i think my problem is how to deal with z and 1/x.
     
  2. jcsd
  3. Feb 26, 2012 #2

    Ray Vickson

    User Avatar
    Science Advisor
    Homework Helper

    Go back and look at what you wrote: you use the matrix A = [(1,1),(1,2),(1,3),(1,4),(1,5),(1,6)], so you are fitting the equation y = a + bx.

    RGV
     
  4. Feb 26, 2012 #3
    do u mean the matrix should be [(1,1),(1,(1/2)),(1,(1/3)),(1,(1/4)),(1,(1/5)),(1,(1/6))]
     
  5. Feb 26, 2012 #4

    Ray Vickson

    User Avatar
    Science Advisor
    Homework Helper

    What do YOU think?

    RGV
     
  6. Feb 26, 2012 #5
    i think thats not right at all and its not funny to trial and error matrix calculations.. they are pretty intense and tiresome

    can you please give me some more hints.. if you know how to do this. because i have no clue anymore.

    EDIT:

    alright it worked..a little miss calculation. thanks for the replies :)
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Method of least squares
  1. Least squares (Replies: 8)

  2. Least Squares (Replies: 3)

Loading...