• Support PF! Buy your school textbooks, materials and every day products Here!

Minimizing square of deviation / curve fitting

  • Thread starter exmachina
  • Start date
  • #1
44
0

Homework Statement



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.

Homework Equations


The deviation for the ith data point is simply:

[tex]d_i^2=(y_i-y)^2=(y-bx_i^2-a)^2[/tex]

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:

Answers and Replies

  • #2
Dick
Science Advisor
Homework Helper
26,258
618
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.
 
  • #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
 

Related Threads for: Minimizing square of deviation / curve fitting

Replies
2
Views
3K
  • Last Post
Replies
3
Views
860
  • Last Post
Replies
4
Views
10K
  • Last Post
Replies
2
Views
895
  • Last Post
Replies
12
Views
2K
  • Last Post
Replies
0
Views
859
  • Last Post
Replies
1
Views
1K
  • Last Post
Replies
3
Views
2K
Top