How to use the moving average calculator
- Paste your numbers in order, oldest first, separated by commas, spaces or new lines.
- Enter the window, which is the number of periods in each average.
- Choose the type: simple, weighted (linear) or exponential.
- Read the table of numbers and their moving averages, and the latest average. Export it as CSV for a spreadsheet.
Formula
simple: average of the last n numbers
weighted: (1 x oldest + 2 x next + ... + n x newest) / (n (n + 1) / 2)
exponential: alpha = 2 / (n + 1), average = alpha x new + (1 - alpha) x previous average
exponential starts with the simple average of the first n numbers
The first n - 1 positions have no average because the window is not full yet. With a window of 1, the averages equal the numbers.
Ten numbers, window of 3
For 12, 15, 14, 18, 21, 19, 24, 26, 25 and 30, the first simple average is (12 + 15 + 14) / 3 = 13.67, then 15.67, 17.67, 19.33, 21.33, 23, 25 and finally 27. The weighted average for the first window is (12 x 1 + 15 x 2 + 14 x 3) / 6 = 14.
The exponential average uses alpha = 2 / 4 = 0.5. It starts at 13.67, then 0.5 x 18 + 0.5 x 13.67 = 15.83, then 18.42, 18.71, 21.35, 23.68, 24.34 and 27.17. The exponential and weighted versions react faster to a recent change than the simple one.
Which type to use
A simple average treats every number in the window equally, which makes it easy to explain but slow to react. A weighted average gives newer numbers more influence in a straight line. An exponential average weights all earlier numbers, with weights that fade steadily, and needs only the previous average to update.
A longer window smooths more but lags behind changes more. A short window follows the data closely but keeps more of the noise.
Related statistics
Moving averages are common for sales, temperatures and any series with noise. For the plain average of a set, use the average calculator, for spread use the standard deviation calculator, for a full summary use the descriptive statistics calculator, and for a trend line, the linear regression calculator.
Assumptions and limits
- Numbers are in time order, evenly spaced, with the oldest first.
- The exponential average is seeded with the simple average of the first window, one of two common conventions. Seeding with the first number gives slightly different early values.
- The first n - 1 positions are blank, not filled with partial averages.
- Up to 2,000 numbers are accepted.
Frequently asked questions
How do you calculate a moving average?
Take the average of the most recent n numbers, then slide forward one position and repeat. The table shows the number at each position next to the average of its window.
What is the difference between simple and exponential?
A simple average gives each of the last n numbers the same weight. An exponential average gives every earlier number some weight, with newer numbers counting more and weights fading smoothly with age.
Why are the first values blank?
An average of n numbers needs n numbers. Until the window is full there is no average, so the table shows a note instead of a made-up figure.
What window should I use?
It depends on what you want to see. A short window follows changes quickly, and a long one shows the trend. Try several windows on the same data and compare.