🔮 Linear Regression Fit Calculator
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.
📐 計算公式 / 原理
斜率 a = (nΣxy − ΣxΣy) / (nΣx² − (Σx)²);截距 b = (Σy − aΣx) / n;預測 ŷ = a·x + b
用最小二乘法對至少 2 對 (x, y) 樣本擬合直線 y = ax + b(支援逗號、空格、分號、頓號分隔,可批次貼上多組):斜率 a 由 x、y 的協方差與 x 的方差之比求得,截距 b 保證迴歸線過樣本均值點 (x̄, ȳ)。預測點 x 可留空,留空時只輸出擬合;填寫後代入 ŷ=a·x+b,超出樣本範圍會提示外推。
📐 計算公式與說明
a = (nΣxy − ΣxΣy) / (nΣx² − (Σx)²)
b = (Σy − aΣx) / n
b = (Σy − aΣx) / n
輸入成對資料;預測點 x 可留空(只擬合),填寫後計算 ŷ。