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

  • Context: Undergrad 
  • Thread starter Thread starter visharad
  • Start date Start date
  • Tags Tags
    Curve Fit Non-linear
Click For Summary
SUMMARY

This discussion focuses on finding a non-linear curve of best fit for the given data sets using linear algebra techniques. The user successfully applies the least squares method for a linear model (y = a + bx) and seeks to extend this to a non-linear model (y = a + bx + c cosx). The proposed solution involves using linear algebra to derive the least squares estimates by constructing a matrix (X) that includes both x-values and cos(x) values, ultimately leading to the formula B = (X^{T}X)^{-1}X^{T}Y for the estimates.

PREREQUISITES
  • Understanding of least squares methods for linear regression
  • Familiarity with linear algebra concepts, particularly matrix operations
  • Knowledge of trigonometric functions, specifically cosine
  • Basic calculus for optimization (though not strictly necessary for linear algebra approach)
NEXT STEPS
  • Research how to construct and manipulate matrices in linear algebra
  • Learn about least squares estimation in non-linear models
  • Explore the application of projection onto subspaces in data fitting
  • Study the implementation of regression models using software tools like Python's NumPy or R
USEFUL FOR

Data scientists, statisticians, and anyone involved in curve fitting or regression analysis, particularly those interested in applying linear algebra to non-linear modeling.

visharad
Messages
51
Reaction score
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.
 
Mathematics news on Phys.org
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 y = a + bx + c*cos{x} --or-- Y = XB, 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 B = (X^{T}X)^{-1}X^{T}Y.

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

Similar threads

  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 18 ·
Replies
18
Views
5K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 13 ·
Replies
13
Views
3K
  • · Replies 9 ·
Replies
9
Views
4K
  • · Replies 10 ·
Replies
10
Views
3K
Replies
8
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K