移动平均

简单移动平均

{\displaystyle {\begin{aligned}{\overline {p}}_{\text{SM}}&={\frac {p_{M}+p_{M-1}+\cdots +p_{M-(n-1)}}{n}}\\&={\frac {1}{n}}\sum _{i=0}^{n-1}p_{M-i}.\end{aligned}}}

${\displaystyle {\overline {p}}_{\text{SM}}={\overline {p}}_{{\text{SM}},{\text{prev}}}+{\frac {1}{n}}(p_{M}-p_{M-n}).}$

SMA的主要缺点是，它使比窗口长度短的大量信号通过。更糟糕的是，它实际上将其反转。这可能会导致意外的伪影，例如，平滑结果中的峰值出现在数据中出现波谷的位置。由于某些较高的频率未正确消除，这也导致结果不如预期的平滑。

指数移动平均

${\displaystyle S_{t}=\alpha \times Y_{t}+(1-\alpha )\times S_{t-1}}$

${\displaystyle EMA_{t}=\alpha \times p_{t}+(1-\alpha )\times EMA_{t-1}=EMA_{t-1}+\alpha \times (p_{t}-EMA_{t-1})}$

${\displaystyle EMA_{t-1}}$递回代入：

${\displaystyle EMA_{t}=\alpha \times (p_{t}+(1-\alpha )p_{t-1}+(1-\alpha )^{2}p_{t-2}+(1-\alpha )^{3}p_{t-3}+\cdots )}$

${\displaystyle {\text{EMA權 重}}\;=\alpha \times {\Big [}1+(1-\alpha )+(1-\alpha )^{2}+(1-\alpha )^{3}+\cdots +(1-\alpha )^{N}{\Big ]}}$
${\displaystyle \qquad \qquad \;={\Big [}1-(1-\alpha )^{N+1}{\Big ]}}$

${\displaystyle {{(1+N)} \over 2}={1 \over \alpha },\quad \alpha ={2 \over {(N+1)}}}$

${\displaystyle 1-(1-\alpha )^{N+1}=1-\left(1-{2 \over (N+1)}\right)^{N+1}\approx 1-{\mbox{e}}^{-2}\approx 86\%}$ ;

${\displaystyle k={\log _{e}(0.001) \over {\log _{e}(1-\alpha )}}\approx {\log _{e}(0.001) \over {-\alpha }}\approx 3.45(N+1)}$ ,

加权移动平均

${\displaystyle WMA_{M}={np_{M}+(n-1)p_{M-1}+\cdots +2p_{M-n+2}+p_{M-n+1} \over n+(n-1)+\cdots +2+1}}$

${\displaystyle WMA_{M+1}={N_{M+1} \over n+(n-1)+\cdots +2+1}}$

累积移动平均

${\displaystyle {\text{CMA}}_{n}={{x_{1}+\cdots +x_{n}} \over n}\,.}$

${\displaystyle {\text{CMA}}_{n+1}={{x_{n+1}+n\cdot {\text{CMA}}_{n}} \over {n+1}}.}$

${\displaystyle x_{1}+\cdots +x_{n}=n\cdot {\text{CMA}}_{n}}$

{\displaystyle {\begin{aligned}x_{n+1}&=(x_{1}+\cdots +x_{n+1})-(x_{1}+\cdots +x_{n})\\[6pt]\end{aligned}}}

{\displaystyle {\begin{aligned}{\text{CMA}}_{n+1}&={x_{n+1}+n\cdot {\text{CMA}}_{n} \over {n+1}}\\[6pt]&={x_{n+1}+(n+1-1)\cdot {\text{CMA}}_{n} \over {n+1}}\\[6pt]&={(n+1)\cdot {\text{CMA}}_{n}+x_{n+1}-{\text{CMA}}_{n} \over {n+1}}\\[6pt]&={{\text{CMA}}_{n}}+{{x_{n+1}-{\text{CMA}}_{n}} \over {n+1}}\end{aligned}}}

参考文献

1. ^ Statistical Analysis, Ya-lun Chou, Holt International, 1975, ISBN 0-03-089422-0, section 17.9.
2. ^ The derivation and properties of the simple central moving average are given in full at Savitzky–Golay filter.
3. ^ NIST/SEMATECH e-Handbook of Statistical Methods: Single Exponential Smoothing页面存档备份，存于互联网档案馆），National Institute of Standards and Technology