📊 Linear Regression Calculator

📐 计算公式
最小二乘线性拟合 y = a·x + b:斜率 a = (nΣxy − Σx·Σy) ÷ [nΣx² − (Σx)²],截距 b = (Σy − a·Σx) ÷ n;R² = (nΣxy − Σx·Σy)² ÷ {斜率分母×[nΣy² − (Σy)²]}(分母为 0 时记 1),r = √|R²|×斜率符号,RMSE = √(SSE ÷ n)。校验:至少 2 组「x,y」数据点,所有 x 相同提示无法拟合直线。判据:R² ≥0.9 线性相关性强、≥0.6 中等相关、其余相关性较弱。
基于最小二乘线性回归,对 n 组 (x,y) 求斜率 a,配合截距 b 得到拟合直线 y=a·x+b,用于趋势预测与相关性分析。

Accepts x,y data pairs, one per line with comma or space separators, and fits a least-squares regression line y=ax+b together with the coefficient of determination R squared.

💡 最小二乘法:斜率 a = (n·Σxy − Σx·Σy) ÷ (n·Σx² − (Σx)²);截距 b = (Σy − a·Σx) ÷ n;相关系数 R² = [ (n·Σxy − Σx·Σy) ]² ÷ [ (n·Σx² − (Σx)²) · (n·Σy² − (Σy)²) ]。

Formula & Standard References

Item Formula / Note Source / Standard
Least squaresMinimise residual sum of squaresLegendre 1805
Regression coefficientsb = Sxy/SxxRegression analysis
Intercepta = ȳ − b·x̄Regression basics
R squaredR² = 1 − SSE/SSTCoefficient of determination
Correlationr = Sxy/√(Sxx·Syy)Pearson 1895
Residual diagnosticsResiduals i.i.d., no trendRegression diagnostics
⚠️ 使用说明与注意事项
  • 至少需要 2 组有效数据点才能拟合
  • 每行格式:x,y(逗号、空格或制表符分隔)
  • R² 越接近1表示线性相关性越强
  • 本工具纯前端运行,数据不会上传到服务器

🕘 最近计算

暂无计算记录