# 2.4 理解指数加权平均数（Understanding exponentially weighted averages ）

指数加权平均公式的一般形式：

$$
\begin{aligned}V\_t
\=&\beta V\_{t-1}+(1-\beta)\theta\_t\\
\=&(1-\beta)\theta\_t+(1-\beta)\cdot\beta\cdot\theta\_{t-1}+(1-\beta)\cdot \beta^2\cdot\theta\_{t-2}+\cdots
+(1-\beta)\cdot \beta^{t-1}\cdot \theta\_1+\beta^t\cdot V\_0
\end{aligned}
$$

$$\theta\_t,\theta\_{t-1},\theta\_{t-2},\cdots,\theta\_1$$是原始数据值，$$(1-\beta),(1-\beta)\beta,(1-\beta)\beta^2,$$$$\cdots,(1-\beta)\beta^{t-1}$$是类似指数曲线，从右向左，呈指数下降的。$$V\_t$$ 的值是这两个子式的点乘，将原始数据值与衰减指数点乘，相当于做了指数衰减，离得越近，影响越大，离得越远，影响越小，衰减越厉害

![](https://2314428465-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Le0cHhI0S0DK8pwlrmD%2F-Le0cKOp1vaxoORIi4ak%2F-Le0cdN6vVwXGqX0BR8A%2F11.bmp?generation=1556953084023835\&alt=media)

为了减少内存的使用，使用这样的语句来实现指数加权平均算法：

$$
V\_{\theta}=0
$$

$$
Repeat\ {
$$

$$
\ \ \ \ Get\ next\ \theta\_t
$$

$$
\ \ \ \ V\_{\theta}:=\beta V\_{\theta}+(1-\beta)\theta\_t
$$

$$
}
$$
