🔮 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

输入成对数据;预测点 x 可留空(只拟合),填写后计算 ŷ。