1.4.3 The least square method used for the linear ...
The least square method is the most accurate one in a series of approximate calculations,by which the best value can be determined from a group of measured values with the same accuracy.Take the linear equation as an example:the slope m and intercept b can be obtained once the line equation is determined.So linear regression(linear fitting)is the process of determining the size of m and b from the experimental data set(xi,yi).
According to the least square method principle,if the best fitted linear equation is Y=f(x),the sums of squares of the deviation values between measured values yi and corresponding values on the fitted line is the minimum,i.e.
![]()
In order to simplify the question,it is supposed that every measured value xi is of equal accuracy,and only yi is accompanied by obviously measured accidental error.Substitute the linear equation into Equation(1.4.1),we may get the following formula:
![]()
So m and b should be solutions to the following equations:

i.e.

Solve Equation(1.4.4)to obtain:

Where

(https://www.daowen.com)
In order to examine the linear fitting,the correlation coefficient is defined as follows:

It can be proved that the absolute value of r always lays between 0 and 1.The closer the absolute value approaches 1,the better the linear relationship between x and y is.
Example 1.4.1
Data is shown in Table 1.4.2.
Table 1.4.2 Measuring results for surface tension coefficient of water α acquired at different temperatures

Suppose the primary function form α=mT+b,where T stands for the thermodynamic temperature.Evaluate m and b by ordinary least squares.Firstly,work the following quantities out:

Then,m and b can be evaluated through Equation(1.4.5)and Equation(1.4.6),i.e.

Finally,the analytic equation for relationship between surface tension coefficient α and temperature T can be concluded as α=-(0.16T+119.6)×103 N/m.
For exponential function,logarithmic function and power function,we can obtain the linear relationship by the variable substitution,which is suitable for least square fitting.
We can also use a computer to perform the linear regression,directly solving the experimental equation and obtaining the relevant parameters and their errors.This approach is now viable due to the popularization of computers.