Confused on Linear Least Square Fits very basic.

  • Context: Undergrad 
  • Thread starter Thread starter bobbo7410
  • Start date Start date
  • Tags Tags
    Confused Linear Square
Click For Summary
SUMMARY

The discussion focuses on performing a linear least squares fit for a set of x and y values, specifically using the example data points: x = [1, 2, 3, 4, 5] and y = [6, 7, 8, 9, 10]. The linear equation is defined as y = mx + b, where "m" represents the slope and "b" the y-intercept. The total square error is calculated by summing the squares of the differences between the calculated values and the actual y values. The optimal values for m and b are found by minimizing this total square error through partial derivatives.

PREREQUISITES
  • Understanding of linear equations and their components (slope and y-intercept).
  • Familiarity with the concept of square error in statistical analysis.
  • Basic knowledge of calculus, specifically partial derivatives.
  • Experience with data representation in tabular form.
NEXT STEPS
  • Learn about the method of least squares in more detail.
  • Explore how to implement linear regression using Python libraries like NumPy or SciPy.
  • Study the implications of overfitting and underfitting in linear models.
  • Investigate alternative regression techniques such as polynomial regression.
USEFUL FOR

Data analysts, statisticians, students learning regression analysis, and anyone interested in applying linear models to datasets.

bobbo7410
Messages
36
Reaction score
0
Quite confused. I've read the book/online definitions yet I suppose I may need a simpler explanation.

Lets say I have a table of x y values.

x 1 2 3 4 5
y 6 7 8 9 10

how would I carry out the linear least squares fit of the data to determine the slope and y-intercept?
 
Physics news on Phys.org
How about you tell us a definition that you've seen (or give us a link to it), and tell us where you get stuck in trying to apply it?
 
As jtbell says, there are a number of equivalent ways to do that. Not necessarily the simplest, but the most direct is this: Let the line be y= mx+ b where "m" is the slope and "b" is the y-intercept. For x= 1, the "calculated value" would be y= m+ h while the true value is 6. The "square error" is (m+ b- 6)^2. Similarly, for x= 2 the "calculated value" would be y= 2m+ b while the true value is 7. The "square error" is (2m+b- 7)^2. Repeating that for all given values, the "total square error" would be (m+ b- 6)^2+ (2m+ b- 7)^2+ (3m+ b- 8)^2+ (4m+ b- 9)^2+ (5m+ b- 10)^2[/math]. To minimize that, take the partial derivatives with respect to m and b and set them equal to 0.<br /> <br /> Of course, for this particular example, it is obvious that the line y= x+ 5 goes exactly through every point so that is what you would get.
 

Similar threads

  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 28 ·
Replies
28
Views
3K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 30 ·
2
Replies
30
Views
5K