📊 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表示線性相關性越強
  • 本工具純前端執行,資料不會上傳到伺服器

🕘 最近計算

暫無計算記錄