Least squares fit to a straight line?

In summary, the conversation discusses how to compute the Least Squares fit to a straight line given N experimental points (xi, yi) and how to calculate the slope (a) and intercept (b) of the line. The process involves setting the partial derivatives of the sum of squared deviations to zero and solving for a and b. The final equation is y = 46.3x + (-61.8). To plot the line, two points can be calculated from the equation and connected. The slope (a) can be used to calculate the acceleration due to gravity (g).
  • #1
noname1
134
0
I was wondering if someone could explain how to compute the Least squares fit to a straight line
 
Physics news on Phys.org
  • #2
You have N experimental points (xi,yi) and you want to fit a straight line y=ax+b across them so that the mean value of the square of the deviations y(xi)-yi is minimum with respect to the parameters a and b
.
[tex]S=\sum_1^N{(ax_i+b-y_i)^2} = minimum[/tex]

For that, the partial derivatives of S have to be zero. This condition yields two equations for a and b.

[tex] \partial S /\partial a=\sum_1^N{2(ax_i+b-y_i)x_i}=0[/tex]
[tex] \partial S /\partial b=\sum_1^N{2(ax_i+b-y_i)}=0[/tex]

Rearranging the equations:

[tex] a\sum_1^N{x_i^2}+b\sum_1^N{x_i}=\sum_1^N{x_i y_i}[/tex]

[tex] a\sum_1^N{x_i}+N b=\sum_1^N{y_i}[/tex]

Solve for a and b.

ehild
 
  • #3
i have solved it and got this

y = 46.3x+(-61.8)

my question is now, i plotted my points on a table on paper but how do i make the straight line?
 
  • #4
Just calculate two points of your equation, put them onto the plot and connect them with a straight line :)

ehild
 
  • #5
how didnt i think of that duhhh lol, one more question now how do i calculate g from the slope?
 

FAQ: Least squares fit to a straight line?

1. What is a least squares fit to a straight line?

A least squares fit to a straight line is a statistical method used to determine the best-fitting line through a set of data points. It minimizes the sum of the squared distances between the data points and the line, resulting in the line that best represents the relationship between the variables.

2. When is a least squares fit to a straight line used?

A least squares fit to a straight line is commonly used in regression analysis to determine the strength and direction of the relationship between two variables. It is also used in data analysis to identify trends and make predictions.

3. What are the assumptions of a least squares fit to a straight line?

The main assumptions of a least squares fit to a straight line are that the relationship between the variables is linear, the errors in the data are normally distributed, and the errors have equal variances. If these assumptions are violated, the results of the analysis may not be accurate.

4. How is a least squares fit to a straight line calculated?

The calculations for a least squares fit to a straight line involve finding the slope and intercept of the line that minimizes the sum of the squared distances between the data points and the line. This is typically done using a regression equation or software.

5. What does the R-squared value in a least squares fit to a straight line represent?

The R-squared value, also known as the coefficient of determination, represents the proportion of variation in the data that is explained by the line. It ranges from 0 to 1, with higher values indicating a stronger relationship between the variables.

Back
Top