Finding the Best Fit Line Using the Method of Least Squares

In summary, the conversation discusses finding the relation between the number of years and the number of accidents using a linear model instead of an inverse one. The correct equation is y = 0.3914 + 11.6945/x, but there were some errors in the calculation process. The solution was found by using the matrix A = [(1,1),(1,2),(1,3),(1,4),(1,5),(1,6)] and the vectors y = [12,6,5,4,2,2] and x = [a,b].
  • #1
Helpeme
8
0

Homework Statement



number of years(x): [1,2,3,4,5,6,]
number of accidents(y): [12,6,5,4,2,2]

or

(1,12),(2,6),(3,5),(4,4),(5,2),(6,2)


Homework Equations



the relation between x and y is on the form: y = a + b(1/x)
by changing (1/x) to z, the model become linear instead of inverse.
use this to 'find' a and b

The Attempt at a Solution



y = a+b(1/x)
z = 1/x
y = a+bz

matrix A = [(1,1),(1,2),(1,3),(1,4),(1,5),(1,6)]
vector y = [12,6,5,4,2,2]
vector x = [a,b]

finds a solution to ATAx = ATy

6a + 21b = 31
21a + 91b = 77

a = 11.4557
b = -1.8

y = 11.4667 - 1.8/x

but this is wrong the right answer is:
y = 0.3914 + 11.6945/x

i think my problem is how to deal with z and 1/x.
 
Physics news on Phys.org
  • #2
Helpeme said:

Homework Statement



number of years(x): [1,2,3,4,5,6,]
number of accidents(y): [12,6,5,4,2,2]

or

(1,12),(2,6),(3,5),(4,4),(5,2),(6,2)


Homework Equations



the relation between x and y is on the form: y = a + b(1/x)
by changing (1/x) to z, the model become linear instead of inverse.
use this to 'find' a and b

The Attempt at a Solution



y = a+b(1/x)
z = 1/x
y = a+bz

matrix A = [(1,1),(1,2),(1,3),(1,4),(1,5),(1,6)]
vector y = [12,6,5,4,2,2]
vector x = [a,b]

finds a solution to ATAx = ATy

6a + 21b = 31
21a + 91b = 77

a = 11.4557
b = -1.8

y = 11.4667 - 1.8/x

but this is wrong the right answer is:
y = 0.3914 + 11.6945/x

i think my problem is how to deal with z and 1/x.

Go back and look at what you wrote: you use the matrix A = [(1,1),(1,2),(1,3),(1,4),(1,5),(1,6)], so you are fitting the equation y = a + bx.

RGV
 
  • #3
do u mean the matrix should be [(1,1),(1,(1/2)),(1,(1/3)),(1,(1/4)),(1,(1/5)),(1,(1/6))]
 
  • #4
Helpeme said:
do u mean the matrix should be [(1,1),(1,(1/2)),(1,(1/3)),(1,(1/4)),(1,(1/5)),(1,(1/6))]

What do YOU think?

RGV
 
  • #5
i think that's not right at all and its not funny to trial and error matrix calculations.. they are pretty intense and tiresome

can you please give me some more hints.. if you know how to do this. because i have no clue anymore.

EDIT:

alright it worked..a little miss calculation. thanks for the replies :)
 

1. What is the Method of Least Squares?

The Method of Least Squares is a statistical technique used to find the line of best fit for a set of data points. It minimizes the sum of the squared differences between the actual data points and the predicted values on the line of best fit.

2. How is the line of best fit determined using the Method of Least Squares?

The line of best fit is determined by finding the values of the slope and y-intercept that minimize the sum of the squared differences between the actual data points and the predicted values on the line. This is done by using a specific formula that takes into account all of the data points.

3. What are the assumptions of the Method of Least Squares?

The main assumptions of the Method of Least Squares are that the data is normally distributed, the errors are independent and have equal variances, and that the relationship between the variables is linear. Additionally, the data should not have any significant outliers.

4. When is the Method of Least Squares used?

The Method of Least Squares is commonly used to analyze and model relationships between two or more variables. It is used in various fields such as economics, engineering, and social sciences to make predictions and understand the strength and direction of relationships between variables.

5. What are the limitations of the Method of Least Squares?

The Method of Least Squares assumes linearity between the variables and may not accurately capture non-linear relationships. It also relies on the normality and independence assumptions, which may not hold true for all data sets. Additionally, it may be sensitive to outliers and influential data points, leading to inaccurate results.

Similar threads

  • General Math
Replies
2
Views
2K
  • Calculus and Beyond Homework Help
Replies
1
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • Calculus and Beyond Homework Help
Replies
4
Views
2K
  • Set Theory, Logic, Probability, Statistics
Replies
4
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
19K
  • Programming and Computer Science
Replies
1
Views
2K
  • Introductory Physics Homework Help
Replies
4
Views
14K
  • Calculus and Beyond Homework Help
Replies
2
Views
3K
  • Set Theory, Logic, Probability, Statistics
Replies
5
Views
4K
Back
Top