In statistics, a moving average (rolling average or running average or moving mean or rolling mean) is a calculation to analyze data points by creating a series of averages of different selections of the full data set. Variations include: simple, cumulative, or weighted forms. Mathematically, a moving average is a type of convolution. Thus in signal processing it is viewed as a low-pass finite impulse response filter. Because the boxcar function outlines its filter coefficients, it is called a boxcar filter. It is sometimes followed by downsampling. 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 series. A moving average is commonly used with time series data to smooth out short-term fluctuations and highlight longer-term trends or cycles - in this case the calculation is sometimes called a time average. The threshold between short-term and long-term depends on the application, and the parameters of the moving average will be set accordingly. It is also used in economics to examine gross domestic product, employment or other macroeconomic time series. When used with non-time series data, a moving average filters higher frequency components without any specific connection to time, although typically some kind of ordering is implied. Viewed simplistically it can be regarded as smoothing the data.
History The technique of moving averages was invented by the Bank of England in 1833 to conceal the state of its bullion reserves.
Simple moving average
In financial applications a simple moving average (SMA) is the unweighted mean of the previous k {\displaystyle k} data-points. However, in science and engineering, the mean is normally taken from an equal number of data on either side of a central value. This ensures that variations in the mean are aligned with the variations in the data rather than being shifted in time. An example of a simple equally weighted running mean is the mean over the last k {\displaystyle k} entries of a data-set containing n {\displaystyle n} entries. Let those data-points be p 1 , p 2 , … , p n {\displaystyle p_{1},p_{2},\dots ,p_{n}} . This could be closing prices of a stock. The mean over the last k {\displaystyle k} data-points (days in this example) is denoted as SMA k {\displaystyle {\textit {SMA}}_{k}} and calculated as:
SMA k = p n − k + 1 + p n − k + 2 + ⋯ + p n k = 1 k ∑ i = n − k + 1 n p i {\displaystyle {\begin{aligned}{\textit {SMA}}_{k}&={\frac {p_{n-k+1}+p_{n-k+2}+\cdots +p_{n}}{k}}\\&={\frac {1}{k}}\sum _{i=n-k+1}^{n}p_{i}\end{aligned}}}
… excerpt ends here. Continue reading the full article.






