正交投影
u 在直线上的投影是直线上离 u 最近的点。残差 u − proj(u) 与直线垂直,这正是最小二乘的几何核心。
6 分钟难度 2/3交互演示区域不展示广告。
u · v1.41Projection length1.41Residual0.89Angle32.3°
The cyan arrow is the closest point to u on the line. The rose residual is perpendicular to the line — that right angle is exactly what makes least squares work. Change the direction or move u to see the projection and residual update.
你看到的是什么
1
投影长度为 (u · v) / |v|,投影向量等于该标量乘以 v 的单位方向。
2
残差 r = u − p 与 v 垂直,因此三角形在 p 点处是直角。
3
在直线上的所有点中,p 到 u 的距离最小。这就是最小二乘找到最近拟合的原因。
为什么重要
投影是回归、傅里叶系数、信号逼近和求解矛盾线性方程组背后的几何。
复杂度与细节
投影到直线对 Rⁿ 中向量为 O(n)。投影到子空间需要求解正规方程。
常见问题
为什么残差是正交的?+
如果残差沿直线有分量,稍微移动投影点就能缩短距离。距离最小迫使残差与直线垂直。
如果向量已经在直线上呢?+
此时投影等于原向量,残差为零。该点已经是最接近的点。