ArticleslgStudy

mathematics

Moving average

Moving average is a mathematics topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Moving average rather than just read about it. In short: In statistics, a moving average (also rolling average, running average, 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.

Moving average — main illustration
Moving average — illustration

Key takeaways

  • Moving average belongs to mathematics; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Moving average to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Moving average from memory before moving on to harder problems.

Reference excerpt

In statistics, a moving average (also rolling average, running average, 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 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 entries of a data-set containing n entries. Let those data-points be p1,p2,…,pn. This could be closing prices of a stock. The mean over the last k data-points (days in this example) is denoted as 𝑆𝑀𝐴k and calculated as: 𝑆𝑀𝐴k=pn−k+1+pn−k+2+⋯+pnk=1k∑i=n−k+1npi When calculating the next mean 𝑆𝑀𝐴k,next with the same sampling width k the range from n−k+2 to n+1 is considered. A new value pn+1 comes into the sum and the oldest value pn−k+1 drops out. This simplifies the calculations by reusing the previous mean 𝑆𝑀𝐴k,prev. 𝑆𝑀𝐴k,next=1k∑i=n−k+2n+1pi=1k(pn−k+2+pn−k+3+⋯+pn+pn+1⏟∑i=n−k+2n+1pi+pn−k+1−pn−k+1⏟=0)=1k(pn−k+1+pn−k+2+⋯+pn)⏟=𝑆𝑀𝐴k,prev−pn−k+1k+pn+1k=𝑆𝑀𝐴k,prev+1k(pn+1−pn−k+1) This means that the moving average filter can be computed quite cheaply on real time data with a FIFO / circular buffer and only 3 arithmetic steps. During the initial filling of the FIFO / circular buffer the sampling window is equal to the data-set size thus k=n and the average calculation is performed as a cumulative moving average. The period selected (k) depends on the type of movement of interest, such as short, intermediate, or long-term. If the data used are not centered around the mean, a simple moving average lags behind the latest datum by half the sample width. An SMA can also be disproportionately influenced by old data dropping out or new data coming in. One characteristic of the SMA is that if the data have a periodic fluctuation, then applying an SMA of that period will eliminate that variation (the average always containing one complete cycle). But a perfectly regular cycle is rarely encountered. For a number of applications, it is advantageous to avoid the shifting induced by using only "past" data. Hence a central moving average can be computed, using data equally spaced on either side of the point in the series where the mean is calculated. This requires using an odd number of points in the sample window. A major drawback of the SMA is that it lets through a significant amount of the signal shorter than the window length. This can lead to unexpected artifacts, such as peaks in the smoothed result appearing where there were troughs in the data. It also leads to the result being less smooth than expected since some of the higher frequencies are not properly removed. Its frequency response is a type of low-pass filter called sinc-in-frequency (or, in discrete time, is a Dirichlet kernel).

Continuous moving average The continuous moving average of an integrable function f:ℝ→ℝ is defined via integration as:

Mf,ε:ℝ→ℝx↦12ε∫x−εx+εf(t)dt where the ε environment [x−ε,x+ε] around x defines the intensity of smoothing of the graph of the integrable function. A larger ε>0 smooths the source graph of the function (blue) f more. The animations below show the moving average as animation in dependency of different values for ε>0. The fraction 12ε is used, because 2ε is the interval width for the integral. Naturally, limε→0Mf, ε=f by fundamental theorem of calculus and L'Hôpital's rule.

… excerpt ends here. Continue reading the full article.

Illustrations

Moving average: Smoothing of a noisy sine (blue curve) with a moving average (red curve).
Smoothing of a noisy sine (blue curve) with a moving average (red curve).
Moving average illustration
Moving average illustration
Moving average illustration
Moving average illustration

Worked examples

Example 1 — a first encounter with Moving average

Start with the simplest possible case. Write down what Moving average claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In mathematics, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Moving average before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Moving average ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Moving average

In research
Moving average appears in mathematics research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Moving average in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Moving average is common in secondary-school and first-year university syllabi. It links to neighbouring topics Chart overlays, Statistical charts and diagrams, Technical analysis, so understanding it makes those chapters shorter.
In everyday life
Look for Moving average outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Moving average” →

How to study Moving average in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Moving average means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Moving average out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Moving average in simple terms?

In statistics, a moving average (also rolling average, running average, 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.

Why does Moving average matter?

Because it connects several mathematics ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Moving average?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Moving average.

Tags

  • Chart overlays
  • Statistical charts and diagrams
  • Technical analysis
  • Time series

Keep exploring