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!

Minimizing square of deviation / curve fitting

  1. May 22, 2009 #1
    1. The problem statement, all variables and given/known data

    Given some data set, (x,y), fit to the the curve [tex]y=bx^2+a[/tex] by minimizing the square of the deviation. Preferred to use matrices.

    2. Relevant equations
    The deviation for the ith data point is simply:


    3. The attempt at a solution

    If I understand correctly, I want to minimize [tex]\sum{d_i^2}[/tex] by differentiating wrt to a and b and setting to zero to find the local minima. So far I have differentiated to yield the following system of equations:

    [tex]\sum_{i}^n y_i = an + \sum_{i}^n bx_i^2 [/tex]

    [tex]\sum_{i}^n{x_i^2y_i}=a\sum_{i}^n x_i^2 + b \sum_{i}^n x_n^4[/tex]

    So I'm stuck using either Cramer's Rule, LU, or GE. Cramer's Rule is the easiest to implement, but I don't know how much slower it will be compared to LU/GE. I have around 300 data points
    Last edited: May 22, 2009
  2. jcsd
  3. May 22, 2009 #2


    User Avatar
    Science Advisor
    Homework Helper

    It doesn't really matter what method you use, there are only two unknowns, a and b. It's a 2x2 system. Once you have found the summations of the various powers of your data points, it's easy.
  4. May 22, 2009 #3
    Solving the system using Cramer's rule is very simple.

    [tex] a = \frac { \sum x^{4}_{i} \sum y_{i} - \sum x^{2}_{i} \sum x^{2}_{i} y_{i}} {n \sum x^{4}_{i }- ( \sum x^{2}_{i})^2} [/tex]

    [tex] b = \frac { n \sum x^{2}_{i} y_{i} - \sum x^{2}_{i} \sum y_{i}} {n \sum x^{4}_{i }- ( \sum x^{2}_{i})^2} [/tex]

    and then calculate the sums using a spreadsheet
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Similar Discussions: Minimizing square of deviation / curve fitting
  1. Minimizing a curve (Replies: 0)