How to find curve (non-linear) of best fit?

  • Thread starter visharad
  • Start date
  • #1
54
0
Given the following sets of data, find the curve of best fit
x = -4, -6, 5, -6, -9, -2, 5
y = -4, -7, 3, -12, -2, 5, 7

a) y = a + bx
b) y = a + bx + c cosx

I can do part a by using the formula for least square methods for straight line. But what about part b? One way I can think of is to do the following
Use Calculus to minimize the value of Sum(a + bx + c cosx - y)^2 and derive equations for a, b and c.
But this problem is for linear algebra. So I am thinking if we can solve it without using calculus.
 

Answers and Replies

  • #2
806
23
The second model is still a linear model; derive the least squares estimates through the usual method (good luck though, there are very few data points and they're scattered all over the place).

Using linear algebra...
Fit the model [itex]y = a + bx + c*cos{x}[/itex] --or-- [itex]Y = XB[/itex], where...
Y = Column vector of y-values
X = A 7x3 matrix where the first column consists of ones, the second contains x-values, and the third contains
cos(x) values.

Then the matrix of least squares estimates (B) is given by [itex]B = (X^{T}X)^{-1}X^{T}Y[/itex].

You remember projection onto subspaces, right? You're just projecting y onto the subspace spanned by x.
 
Last edited:

Related Threads on How to find curve (non-linear) of best fit?

Replies
4
Views
3K
  • Last Post
Replies
4
Views
2K
Replies
1
Views
577
  • Last Post
Replies
6
Views
3K
Replies
2
Views
1K
Replies
9
Views
7K
  • Last Post
Replies
4
Views
679
Replies
6
Views
1K
Replies
5
Views
3K
Top