Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Least Square Fitting Line

  1. Apr 8, 2008 #1

    I need to use the Least Square Fitting approach to calculating the best line of fit.

    I have read loads, and cant seem to figure out how to get passed the Inverse matrix part?

    Anyone know any good links, or can guide me on how to do least square fitting?

  2. jcsd
  3. Apr 8, 2008 #2


    User Avatar
    Staff Emeritus
    Science Advisor

    There are about a dozen different way of finding "least squares" lines, some of which use matrices. What matrix are finding an Inverse matrix for? What do you mean "get passed the inverse matrix".
  4. Apr 9, 2008 #3
    Ok, here is what i have done

    I have matrix "A" Matric "B".

    Using Matrix "A" i can get "Matrix C"

    I then inverse matrix "C", However, the numerical approach i am taking is giving me the wrong matrix where i compare it with a inverse from Maple

    here is my matrix C

    [ 4 ] [ 8 ]
    [ 8 ] [26]

    From this i get det (40)

    I know the answer is

    1/20 [13][-4]
    [-4][ 2]

    I however dont get this...

    So i am stuck on inversing the matrix.

    i get det C at 1/40 and not 1/20
  5. Apr 9, 2008 #4


    User Avatar
    Staff Emeritus
    Science Advisor

    Since you refuse to show us what you did I can only suggest one thing: have you considered reducing fractions?
  6. Apr 12, 2008 #5

    I have solved this now...

    I never transposed matrix "A" to for ATA, once i have transposed then i got all the values for the determinent and inverse and ultimatly the solution.

    Matrix A and B:

    [■(1&1@1&3@1&7@1&4)] [■(C@D)]= [■(3@8@5@7)]

    Transpose A to produce ATA

    A^T A= [■(1&1&1&1@1&3&7&4)] [■(1&1@1&3@1&7@1&4)]= [■(4&15@15&75)]

    This is how i solved it. thanks again for the help.
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?

Similar Discussions: Least Square Fitting Line
  1. 3D Least Squares Fit (Replies: 3)

  2. Least squares fit (Replies: 7)