# Centered Moving Average

This online calculator calculates centered moving average, which is used instead of moving average then number of periods is even

Let's start from a bit of theory.

In statistics, a moving average (rolling average or running average) is a calculation to analyze data points by creating series of averages of different subsets of the full data set. It is also called a moving mean (MM) or rolling mean and is a type of finite impulse response filter... Given a series of numbers and a fixed subset size, the first element of the moving average is obtained by taking the average of the initial fixed subset of the number series. Then the subset is modified by "shifting forward"; that is, excluding the first number of the series and including the next value in the subset. A moving average is commonly used with time series data to smooth out short-term fluctuations and highlight longer-term trends or cycles.^{1}

Moving average described above is also called **one-sided moving average**, and can be expressed using the following formula:

, where *t* changes from *k+1* to *n*.

There is also **two-sided moving average**, which can be expressed as:

, where *t* changes from *k+1* to *n-k*.

The difference is the placement of the moving average. For one-sided moving average the moving average is placed at the end of values being averaged. For two-sided moving average the moving average is centered at the middle of the values being averaged. Here is a little example for 3 periods moving average

Values | One-sided 3MA | Two-sided 3MA |
---|---|---|

4 | N/A | N/A |

5 | N/A | 4 |

3 | 4 | 4 |

4 | 4 | 4 |

5 | 4 | N/A |

Two-sided moving averages are used to smooth a time series and be able to estimate or see the trend, one-sided moving averages can be used as simple forecasting method.

As you can see, both types of moving averages use odd number of periods. However, when working with time series you often smooth to remove seasonality effects, which requires period to be equal to seasonal length, which is often an even number, for example, 12 months or 4 quarters. Where to place two-sided moving average value is case of even smoothing period?

The solution is **centered moving average**. Idea is simple. Let's consider 4-period MA. At given time *t* we can calculate either or . In the first case, we can say that we have and in the second case - . Now we can smooth the smoothed values again, and get .

It is our **centered moving average (CMA)** aka 2*4 MA. Note that smoothing moving averages by another moving average in general is known as **double moving average** and CMA is the example of it (2*n MA).

The calculator below plots CMA for given time series and period (even value). If you want to smooth the edges it simply adds first and last values to calculation, as needed.

## Comments