algo-forecast-exponential
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseExponential Smoothing
指数平滑法
Overview
概述
Exponential smoothing assigns exponentially decreasing weights to past observations. Three variants: Simple (SES, level only), Holt (level + trend), Holt-Winters (level + trend + seasonality). ETS framework (Error-Trend-Seasonality) provides a unified statistical model. Fast, interpretable, and competitive with complex models for short horizons.
指数平滑法为历史观测值分配呈指数递减的权重。包含三种变体:简单指数平滑(SES,仅考虑水平项)、Holt双参数指数平滑(水平项+趋势项)、Holt-Winters三参数指数平滑(水平项+趋势项+季节性项)。ETS框架(误差-趋势-季节性)提供了统一的统计模型。该方法运算快速、可解释性强,在短期预测场景下可与复杂模型相媲美。
When to Use
适用场景
Trigger conditions:
- Quick forecasting with minimal configuration
- Short-horizon forecasts (1-2 seasonal cycles ahead)
- Data with clear level, trend, and/or seasonal components
When NOT to use:
- For long-range forecasts (uncertainty accumulates too fast)
- When external regressors are important (use regression or ML models)
触发条件:
- 只需极少配置的快速预测
- 短期预测(未来1-2个周期的季节性数据)
- 具有明显水平项、趋势项和/或季节性项的数据
不适用场景:
- 长期预测(不确定性累积过快)
- 外部回归因子很重要的场景(使用回归模型或机器学习模型)
Algorithm
算法
IRON LAW: Smoothing Parameters Control the Bias-Variance Trade-Off
α (level), β (trend), γ (seasonality) range [0,1].
- α near 1: react quickly to changes, noisy forecasts (high variance)
- α near 0: smooth forecasts, slow to adapt (high bias)
Optimize via minimizing MSE on training data (or use information criteria).
Never hand-pick smoothing parameters without validation.IRON LAW: Smoothing Parameters Control the Bias-Variance Trade-Off
α (level), β (trend), γ (seasonality) range [0,1].
- α near 1: react quickly to changes, noisy forecasts (high variance)
- α near 0: smooth forecasts, slow to adapt (high bias)
Optimize via minimizing MSE on training data (or use information criteria).
Never hand-pick smoothing parameters without validation.Phase 1: Input Validation
阶段1:输入验证
Identify components: level only (SES), level+trend (Holt), level+trend+seasonality (Holt-Winters). Determine: additive vs multiplicative trend/seasonality.
Gate: Component structure identified, seasonal period known.
识别数据成分:仅水平项(SES)、水平项+趋势项(Holt)、水平项+趋势项+季节性项(Holt-Winters)。确定:加法型 vs 乘法型趋势/季节性。
检查点: 已识别成分结构,已知季节性周期。
Phase 2: Core Algorithm
阶段2:核心算法
Holt-Winters (additive):
- Initialize: level₀ = mean(first season), trend₀ = (mean(season 2) - mean(season 1))/s, seasonal₀ from first season deviations
- Update equations at each t:
- Level: ℓₜ = α(yₜ - sₜ₋ₛ) + (1-α)(ℓₜ₋₁ + bₜ₋₁)
- Trend: bₜ = β(ℓₜ - ℓₜ₋₁) + (1-β)bₜ₋₁
- Seasonal: sₜ = γ(yₜ - ℓₜ) + (1-γ)sₜ₋ₛ
- Forecast: ŷₜ₊ₕ = ℓₜ + h×bₜ + sₜ₊ₕ₋ₛ
Holt-Winters(加法型):
- 初始化:level₀ = 第一个周期的均值,trend₀ = (第二个周期均值 - 第一个周期均值)/s,seasonal₀ 来自第一个周期的偏差值
- 每个时间步t的更新公式:
- 水平项:ℓₜ = α(yₜ - sₜ₋ₛ) + (1-α)(ℓₜ₋₁ + bₜ₋₁)
- 趋势项:bₜ = β(ℓₜ - ℓₜ₋₁) + (1-β)bₜ₋₁
- 季节性项:sₜ = γ(yₜ - ℓₜ) + (1-γ)sₜ₋ₛ
- 预测:ŷₜ₊ₕ = ℓₜ + h×bₜ + sₜ₊ₕ₋ₛ
Phase 3: Verification
阶段3:验证
Check: in-sample RMSE, residual patterns. Compare against naive baselines (last value, seasonal naive).
Gate: Beats naive baseline, residuals show no systematic pattern.
检查:样本内RMSE、残差模式。与朴素基线(最后一个值、季节性朴素法)对比。
检查点: 性能优于朴素基线,残差无系统性模式。
Phase 4: Output
阶段4:输出
Return forecasts with smoothed components.
返回包含平滑成分的预测结果。
Output Format
输出格式
json
{
"forecasts": [{"period": "2025-04", "forecast": 1150, "level": 1100, "trend": 20, "seasonal": 30}],
"parameters": {"alpha": 0.3, "beta": 0.1, "gamma": 0.15},
"metadata": {"method": "holt_winters_additive", "seasonal_period": 12, "rmse": 45}
}json
{
"forecasts": [{"period": "2025-04", "forecast": 1150, "level": 1100, "trend": 20, "seasonal": 30}],
"parameters": {"alpha": 0.3, "beta": 0.1, "gamma": 0.15},
"metadata": {"method": "holt_winters_additive", "seasonal_period": 12, "rmse": 45}
}Examples
示例
Sample I/O
输入输出样例
Input: 36 months of monthly sales, clear upward trend, December spike
Expected: Holt-Winters additive. Forecast continues trend with repeated December seasonality.
输入: 36个月的月度销售数据,有明显上升趋势,12月出现峰值
预期结果: 使用Holt-Winters加法型。预测结果延续趋势并重复12月的季节性特征。
Edge Cases
边缘情况
| Input | Expected | Why |
|---|---|---|
| No trend, no seasonality | SES (α only) | Simplest variant suffices |
| Seasonal amplitude grows | Use multiplicative | Additive would underestimate peaks |
| Very short series (<2 seasons) | SES or Holt only | Can't estimate seasonality |
| 输入 | 预期结果 | 原因 |
|---|---|---|
| 无趋势、无季节性 | SES(仅α参数) | 最简单的变体已足够 |
| 季节性幅度随水平增长 | 使用乘法型 | 加法型会低估峰值 |
| 极短序列(<2个周期) | SES或仅Holt | 无法估计季节性 |
Gotchas
注意事项
- Additive vs multiplicative: If seasonal swings grow proportionally with level, use multiplicative. Wrong choice produces poor forecasts, especially at extremes.
- Initialization sensitivity: The first season's values set the baseline. Poor initialization from noisy early data propagates through the entire forecast.
- Damped trend: For long horizons, linear trend extrapolation is unrealistic. Use damped trend (φ parameter) to flatten the trend over time.
- Multiple seasonalities: Standard Holt-Winters handles one seasonal period. For daily data with weekly AND yearly patterns, use TBATS or STL+ETS.
- Outlier sensitivity: A single outlier can shift the level estimate significantly (especially with high α). Pre-detect and handle outliers.
- 加法型vs乘法型:如果季节性波动随水平成比例增长,使用乘法型。选择错误会导致预测效果差,尤其是在极端值时。
- 初始化敏感性:第一个周期的值设定了基线。早期噪声数据导致的初始化不当会影响整个预测过程。
- 阻尼趋势:对于长期预测,线性趋势外推不现实。使用阻尼趋势(φ参数)使趋势随时间趋平。
- 多季节性:标准Holt-Winters仅处理一个季节性周期。对于同时具有周度和年度模式的日度数据,使用TBATS或STL+ETS。
- 异常值敏感性:单个异常值会显著改变水平估计(尤其是当α值较高时)。需预先检测并处理异常值。
References
参考资料
- For ETS framework and model selection, see
references/ets-framework.md - For damped trend variants, see
references/damped-trend.md
- 关于ETS框架和模型选择,参见
references/ets-framework.md - 关于阻尼趋势变体,参见
references/damped-trend.md