2.2 Exponentially Moving Average

We're aiming to create a knowledge hub for 3D printing of the future.

Exponentially moving average (EMA) is widely used in signal processing to filter or predict time serial data, such as stock price, see Fig.1. The definition of EMA is shown in Eq.1 where the estimated value at current step v_k is a weighted sum between previously estimated value v_{k-1} and currently observed value \theta_k, and the weight is \gamma.

(1)   \begin{equation*} v_k & = \gamma v_{k-1} + (1 - \gamma) \theta_k\end{equation*}

Eq.2 shows the first three iterations of EMA.

(2)   \begin{equation*} \begin{split}v_1 = & \: (1 - \gamma) \theta_1 \\v_2 = & \:\gamma v_1 + (1 - \gamma) \theta_2 \\& \:\gamma (1 - \gamma) \theta_1 + (1 - \gamma) \theta_2 \\v_3 = & \: \gamma v_2 + (1 - \gamma) \theta_3 \\& \: \gamma^2 (1 - \gamma) \theta_1 + \gamma (1 - \gamma) \theta_2 +(1 - \gamma) \theta_3 \\\end{split}\end{equation*}

Figure 1: An example of 20-period EMA on stock market

Theoretically, EMA considers all previously observed values, but their weights decrease exponentially. For example, for the current estimated value, the observed value from t steps ago is weighted by \gamma^{t-1}(1 - \gamma). Therefore, we usually define the window width of EMA as \frac{1}{1 - \gamma} which means for \gamma = 0.9, the window width is about 10 and weight from 10 step ago is 0.0387 which is small enough. The blue line in Fig.1 shows the 20-period EMA of the stock price estimation, i.e.,\gamma = 0.95. As we can see from this figure, the blue line is much smoother than the actual data.