# 均方误差

**均方误差**（MSE）是估计量或预测值与被估计量之差的平方的期望值，它既可作为选择估计量的准则，也是回归与预测中衡量精度的标准指标。在二次损失下，估计量的表现由其MSE衡量，而MSE可分解为方差分量与偏差分量<sup>[1](https://link.springer.com/chapter/10.1007/978-3-030-95860-2_1)</sup>。

| 关键事实 | 详情 |
|---|---|
| 定义 | 对于 \( N \) 维参数 \( \theta \) 的估计量 \( \hat{\theta} \)，\( MSE = \mathscr{E} \lVert \hat{\theta} - \theta \rVert^2 \)<sup>[1](https://link.springer.com/chapter/10.1007/978-3-030-95860-2_1)</sup> |
| 分解 | \( MSE = \text{方差} + \text{偏差}^2 \)；对于无偏估计量，MSE等于其方差<sup>[1](https://link.springer.com/chapter/10.1007/978-3-030-95860-2_1)</sup><sup> • </sup><sup>[2](https://www.stat.umn.edu/geyer/5101/notes/n2.pdf)</sup> |
| 最小二乘基线 | 对于噪声方差为 \( \sigma^2 \) 的 \( N \) 个独立高斯变量的均值问题，最小二乘估计量的 \( MSE_{LS} = N\sigma^2 \)<sup>[1](https://link.springer.com/chapter/10.1007/978-3-030-95860-2_1)</sup> |
| James–Stein结果 | 当 \( N \ge 3 \) 时，James–Stein估计量对任意 \( \theta \) 均满足 \( MSE_{JS} < N\sigma^2 \)，因此在维数大于二时最小二乘是不可容许的<sup>[1](https://link.springer.com/chapter/10.1007/978-3-030-95860-2_1)</sup> |
| 预测中的作用 | 最小化RMSE的预测方法给出均值的预测，而最小化MAE的方法给出中位数的预测<sup>[3](https://otexts.robjhyndman.com/fpp2/accuracy.html)</sup> |
| 尺度依赖性 | MSE不是无量纲的：以美元为单位的数据得到的MSE单位是美元的平方，因此无法在不同单位的序列之间比较精度<sup>[4](https://otext.robjhyndman.com/hyndsight/forecastmse/)</sup> |
| 方差分析中的用法 | 在方差分析中，\( MSE = SSE/DFE \)，即误差均方，而F检验统计量为 \( F = MST/MSE \)<sup>[5](https://www.itl.nist.gov/div898/handbook/prc/section4/prc423.htm)</sup> |

## 定义与偏差—方差分解

给定参数向量 \( \theta \)（其分量为 \( \theta_i \)）的估计量 \( \hat{\theta} \)，均方误差为

\[ MSE_{\hat{\theta}} = \mathscr{E} \lVert \hat{\theta} - \theta \rVert^2 = \sum_{i=1}^N \mathscr{E}(\hat{\theta}_i - \mathscr{E}\hat{\theta}_i)^2 + \sum_{i=1}^N (\theta_i - \mathscr{E}\hat{\theta}_i)^2, \]

其中第一个和式是估计量的方差，第二个和式是偏差的平方，即估计量均值与参数真值之差<sup>[1](https://link.springer.com/chapter/10.1007/978-3-030-95860-2_1)</sup>。若估计量的均值与 \( \theta \) 重合，则称该估计量无偏，其MSE化为方差<sup>[1](https://link.springer.com/chapter/10.1007/978-3-030-95860-2_1)</sup>。课程讲义中把这一恒等式表述为“均方误差等于方差加偏差的平方”<sup>[2](https://www.stat.umn.edu/geyer/5101/notes/n2.pdf)</sup>。

这一分解之所以重要，是因为无偏性只是一种约束，而非精度的保证。一个偏差很小的估计量可能具有小得多的方差，从而具有更小的均方误差<sup>[6](https://jiahaotian-stat.github.io/Notes/en/Advanced_Stat/5Admissibility/)</sup>。一个具体的例证来自方差估计：在两个常见的方差估计量中，若以均方误差为准则，无偏的那个反而是较差的选择，而最小MSE估计量则接受一定偏差以换取方差的降低<sup>[2](https://www.stat.umn.edu/geyer/5101/notes/n2.pdf)</sup>。

## 最小二乘及其起源

最小化误差平方和的方法即最小二乘法，其历史与MSE准则直接相关。勒让德（Legendre）于1805年发表了最小二乘法，将其作为近似工具发展出来，其中并不假定随机性；高斯（Gauss）自称自1795年起便使用这一原理，于1809年在随机变量与分布的框架下发表了它，这一处理常被视为数理统计的开端<sup>[7](https://link.springer.com/article/10.1007/s00407-022-00291-w)</sup><sup> • </sup><sup>[8](https://en.wikisource.org/wiki/Page%3AA_Source_Book_in_Mathematics_%28Smith%29.pdf/608)</sup>。高斯后来更偏爱他1823年基于最佳线性无偏估计对最小二乘的论证，而非1809年的分析<sup>[7](https://link.springer.com/article/10.1007/s00407-022-00291-w)</sup>。从一个天文学问题出发，平方误差最小化成长为一种工具，构成了线性回归、计量经济学、机器学习和数值线性代数的基础<sup>[9](https://ekonometria.org/en/podstawy/mnk-gauss/)</sup>。

在高斯均值问题中，最小二乘估计量就是观测向量 \( \hat{\theta}^{LS} = Y \)。它是无偏的，因此其MSE等于其方差，该方差不随 \( \theta \) 变化，等于 \( N\sigma^2 \)<sup>[1](https://link.springer.com/chapter/10.1007/978-3-030-95860-2_1)</sup>。

## James–Stein结果

MSE准则引出统计学中最引人注目的发现之一。斯坦（Stein）在20世纪50年代的工作，经詹姆斯与斯坦推广，表明引入偏差可以在整个参数空间上优于最小二乘<sup>[1](https://link.springer.com/chapter/10.1007/978-3-030-95860-2_1)</sup>。对于 \( N \) 个独立高斯观测 \( y_i \sim \mathscr{N}(\theta_i, \sigma^2) \)，James–Stein估计量为

\[ \hat{\theta}^{JS} = Y - \frac{(N-2)\sigma^2}{\lVert Y \rVert^2} Y, \]

且当 \( N \ge 3 \) 时，其MSE对任意 \( \theta \) 均满足 \( MSE_{JS} < N\sigma^2 \)<sup>[1](https://link.springer.com/chapter/10.1007/978-3-030-95860-2_1)</sup>。若一个估计量的MSE对所有 \( \theta \) 都不大于另一个、且对某些 \( \theta \) 更小，则称前者优于后者；没有更优者的估计量称为可容许的。因此该定理表明，一旦维数超过二，多元高斯均值的最小二乘估计量便是不可容许的<sup>[1](https://link.springer.com/chapter/10.1007/978-3-030-95860-2_1)</sup>。

其机制是一种偏差—方差权衡：将 \( Y \) 向原点收缩所引入的偏差，由方差的更大降低所补偿<sup>[1](https://link.springer.com/chapter/10.1007/978-3-030-95860-2_1)</sup>。收缩因子由数据设定，取信噪比估计值的倒数，该估计量也可重新表述为一种正则化最小二乘<sup>[1](https://link.springer.com/chapter/10.1007/978-3-030-95860-2_1)</sup>。改善在于总体的MSE，而非每个 \( \theta_i \) 各自的误差，这在那些不愿以更高的个体MSE换取更小总体MSE的应用中很重要<sup>[1](https://link.springer.com/chapter/10.1007/978-3-030-95860-2_1)</sup>。这一结果在解释上也有局限：当某一坐标的真值很大而其余坐标接近零时，向零收缩为了保证在其余坐标上表现良好，可能会把大坐标过度收缩<sup>[10](https://stat210a.berkeley.edu/fall-2024/reader/jamesstein.html)</sup>。

## 在预测与模型评估中的使用

在预测中，平方误差度量是标准的尺度依赖型精度指标之一。均方根误差为 \( RMSE = \sqrt{\text{mean}(e_t^2)} \)，由预测误差 \( e_t \)（观测值与预测值之差）计算得到<sup>[3](https://otexts.robjhyndman.com/fpp2/accuracy.html)</sup>。由于这些度量与数据同尺度，它们不能用于比较不同单位的序列之间的精度；若数据以美元为单位，MSE的单位便是美元的平方<sup>[3](https://otexts.robjhyndman.com/fpp2/accuracy.html)</sup><sup> • </sup><sup>[4](https://otext.robjhyndman.com/hyndsight/forecastmse/)</sup>。

选择平方误差还是绝对误差，也会改变被估计的对象。最小化MAE的预测方法给出中位数的预测，而最小化RMSE则给出均值的预测，这正是RMSE尽管较难解释却仍被广泛使用的原因<sup>[3](https://otexts.robjhyndman.com/fpp2/accuracy.html)</sup>。平方误差度量对离群预测误差也很敏感<sup>[11](https://pmc.ncbi.nlm.nih.gov/articles/PMC5270768/)</sup>，一个偶发大误差的方法在RMSE上的表现会比在MAE上更差<sup>[12](https://wiki.wfmlabs.org/wiki/Forecast_Accuracy)</sup>。

一个度量在统计上的最优性并不保证其实用价值。在一项针对电池储能系统的日前电价预测评估研究中，RMSE和MAE都与交易所得收益仅呈弱相关，而衡量预测与实际日价格曲线吻合程度的指标则与盈利能力关系更强<sup>[13](https://arxiv.org/abs/2511.13616)</sup>。

## 相关用途与实现

在方差分析中，MSE有一种不同的具体含义：误差均方，由误差平方和除以其自由度得到，\( MSE = SSE/DFE \)。当均值相等的原假设为真时，处理均方与误差均方估计的是同一个误差方差，二者之比接近1；F检验统计量为 \( F = MST/MSE \)<sup>[5](https://www.itl.nist.gov/div898/handbook/prc/section4/prc423.htm)</sup>。

在机器学习实践中，MSE作为标准的回归损失来实现。scikit-learn的函数 `mean_squared_error` 计算真实目标值与预测目标值之间的损失，接受可选的样本权重，返回一个非负浮点值，其最佳值为0.0；对于多输出输入，它可以返回各输出的误差或等权平均值<sup>[14](https://scikit-learn.org/stable/modules/generated/sklearn.metrics.mean_squared_error.html)</sup>。

## References

1. [Pillonetto, G. et al. Bias (introductory chapter), Springer.](https://link.springer.com/chapter/10.1007/978-3-030-95860-2_1)
2. [Geyer, C. J. Stat 5101 Course Notes, University of Minnesota.](https://www.stat.umn.edu/geyer/5101/notes/n2.pdf)
3. [Hyndman, R. J. & Athanasopoulos, G. Forecasting: Principles and Practice, 2nd ed., ch. 3.4, Evaluating forecast accuracy.](https://otexts.robjhyndman.com/fpp2/accuracy.html)
4. [Hyndman, R. J. Forecast estimation, evaluation and transformation.](https://otext.robjhyndman.com/hyndsight/forecastmse/)
5. [NIST/SEMATECH e-Handbook of Statistical Methods, section 7.4.2.3, The ANOVA table.](https://www.itl.nist.gov/div898/handbook/prc/section4/prc423.htm)
6. [Jiahao Tian, Ch. 5: Admissibility, Shrinkage, and the James–Stein Phenomenon.](https://jiahaotian-stat.github.io/Notes/en/Advanced_Stat/5Admissibility/)
7. [Magnus, J. R. (2022). Gauss on least-squares and maximum-likelihood estimation. Archive for History of Exact Sciences 76, 425–430.](https://link.springer.com/article/10.1007/s00407-022-00291-w)
8. [A Source Book in Mathematics (Smith), page 608, Wikisource.](https://en.wikisource.org/wiki/Page%3AA_Source_Book_in_Mathematics_%28Smith%29.pdf/608)
9. [The Method of Least Squares: History, Theory and Proofs, Ekonometria.org.](https://ekonometria.org/en/podstawy/mnk-gauss/)
10. [The James–Stein Estimator, Stat 210A reader, UC Berkeley.](https://stat210a.berkeley.edu/fall-2024/reader/jamesstein.html)
11. [Case study in evaluating time series prediction models using the relative mean absolute error, PMC.](https://pmc.ncbi.nlm.nih.gov/articles/PMC5270768/)
12. [Forecast Accuracy Metrics, WFM Labs wiki.](https://wiki.wfmlabs.org/wiki/Forecast_Accuracy)
13. [Maciejowska, K., Lipiecki, A. & Uniejewski, B. Statistical and economic evaluation of forecasts in electricity markets: beyond RMSE and MAE. arXiv:2511.13616.](https://arxiv.org/abs/2511.13616)
14. [sklearn.metrics.mean_squared_error, scikit-learn documentation.](https://scikit-learn.org/stable/modules/generated/sklearn.metrics.mean_squared_error.html)

---
*Initially written Sep 17, 2026 · Reviewed: Sep 17, 2026; Sep 19, 2026; Oct 15, 2026 · Edited: Sep 19, 2026; Oct 15, 2026 · Last review: Oct 15, 2026*

Topic: 物质世界与数学 › 数学与统计学 › 统计学与概率论 › Statistical inference, estimation, sampling, and testing › Estimation theory and estimator families › Estimation: overview

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/mean-squared-error

English original: https://www.edgepedia.org/mean-squared-error
