Enter paired (x, y) sample data to fit the line y = ax + b by least squares, output the slope a, intercept b, correlation and goodness of fit, and predict y for any x.
输入成对数据,可指定任意 x 预测 y。
| Item | Formula / Note | Source / Standard |
|---|---|---|
| Least-squares slope and intercept | a = sum(x_i - xbar)(y_i - ybar)/sum(x_i - xbar)^2; b = ybar - a·xbar | Legendre AM (1805), Nouvelles methodes pour la determination des orbites des cometes |
| Goodness of fit | R-squared = r^2; values nearer 1 indicate a better linear fit | Draper NR, Smith H, Applied Regression Analysis (3rd ed.), Wiley |
| Least-squares principle | Minimize the residual sum of squares sum(y_i - yhat_i)^2 | Gauss CF (1809), Theoria Motus Corporum Coelestium |
| Prediction caveat | yhat = a·x + b is reliable only by interpolation within the observed x range | Draper NR, Smith H, Applied Regression Analysis (3rd ed.), Wiley |