Finding the Best Fit Line Using the Method of Least Squares

Click For Summary

Homework Help Overview

The discussion revolves around finding the best fit line using the method of least squares for a dataset relating the number of years to the number of accidents. The original poster presents a model of the form y = a + b(1/x) and attempts to linearize the equation by substituting z = 1/x.

Discussion Character

  • Exploratory, Assumption checking, Mathematical reasoning

Approaches and Questions Raised

  • Participants discuss the setup of the matrix used for calculations and question whether the correct form of the matrix should include the transformed variable (1/x) instead of x. There are attempts to clarify the relationship between the variables and the matrix representation.

Discussion Status

The discussion is active with participants providing insights and questioning the original poster's approach. Some participants suggest reconsidering the matrix setup, while others express frustration with the complexity of the calculations. There is a note of progress as the original poster acknowledges a miscalculation after receiving feedback.

Contextual Notes

Participants are navigating the challenges of matrix calculations and the implications of transforming variables in the context of least squares fitting. There is an acknowledgment of the difficulty in the calculations involved.

Helpeme
Messages
7
Reaction score
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
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
 
do u mean the matrix should be [(1,1),(1,(1/2)),(1,(1/3)),(1,(1/4)),(1,(1/5)),(1,(1/6))]
 
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
 
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 :)
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 4 ·
Replies
4
Views
15K
  • · Replies 3 ·
Replies
3
Views
20K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 3 ·
Replies
3
Views
2K