Moving Average

From Wikiversity
Jump to navigation Jump to search
An example of two moving average curves

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)[1] or rolling mean and is a type of finite impulse response filter. Variations include: simple, and cumulative, or weighted forms (described below).

Two parts of notion "Moving" and "Average" had to be defined mathematically:

  • Moving as additive operation in vector space (continuous) or additive group (discrete). It incorporates to have reference position in space that moves.
  • Average by creating a mean for a subset of the collected data according to the reference position in space (generalized expected value for the reference position)

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. The threshold between short-term and long-term depends on the application, and the parameters of the moving average will be set accordingly. For example, it is often used in technical analysis of financial data, like stock prices, returns or trading volumes. It is also used in economics to examine gross domestic product, employment or other macroeconomic time series. Mathematically, a moving average is a type of convolution and so it can be viewed as an example of a low-pass filter used in signal processing. 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.

Learning Tasks[edit | edit source]

Moving Average calculated in LibreOffice - Demo File moving_average_task1.ods for Learning Resource

This learning resource is based on the Open Community Approach, so all software is Open Source and the learning material by default Creative Commons in Wikiversity:

  • generate random data as an example for historical Stock Quotes data in a spreadsheet document with Libre Office Calc by using the function cosine and/or sine.
  • Apply a moving average on the Wikiversity sample files for this learning resource on GitHub[2]
  • Explain the differences between the blue curve of raw data and the application of moving average (red curve)
  • Add another row in the LibreOffice document moving_average_task1.ods[3],
    • that calculates the a moving average of the last 10 values.
    • Modify the diagram so that the additional moving average is shown as well,
    • Compare the moving average of the predefined last 5 value with the moving average of the last 10 value in the LibreOffice diagram.
  • (CSV2Chart) Load the LibreOffice Calc File moving_average_task1.ods[4] and export one table as CSV file and load the CSV file in CSV2WikiChart-App and create a chart with the Template:Graph:Chart.

Discrete Moving Average: applied on linear interpolated random data
Example of an result of the learning task with a 7 day back-in-time moving average generated with CSV2Chart

  • (COVID-19) In Germany COVID-19 reporting procedure show a pattern, that on weekends less COVID-19 cases are reported. Explain, why a 7 days moving average can be applied on the data and describe why a 6 days or 8 days moving average would be unappropriate. Derive in general first recommendations, how to apply the moving average on specific data.

Submodules[edit | edit source]

See also[edit | edit source]

Notes and references[edit | edit source]

  1. Hydrologic Variability of the Cosumnes River Floodplain (Booth et al., San Francisco Estuary and Watershed Science, Volume 4, Issue 2, 2006)
  2. GitHub Collection of Support Files for Wikiversity Learning Resources (2019) Engelbert Niehaus - GitHub Repository: - ZIP-file for all Learning Resources: - (accessed 2019/09/24)
  3. "Wikiversity Files: LibreOffice Calc ODS File for Learning Resource "Moving Average"". Retrieved 2020-10-09.
  4. "Wikiversity Files". Retrieved 2020-10-09.

External links[edit | edit source]

Download Excel file to calculate SMA & EMA

Subject classification: this is a statistics resource.

Page Information[edit | edit source]

This page was based on the following wikipedia-source page: