WOLFRAM

MovingAverage[list,r]

gives the moving average of list, computed by averaging runs of r elements.

MovingAverage[list,{w1,w2,,wr}]

gives the moving average of list, computed with weights wi.

Details

Examples

open allclose all

Basic Examples  (2)Summary of the most common use cases

Compute a pairwise simple moving average:

Out[1]=1

Compute weighted moving averages:

Out[1]=1

Scope  (5)Survey of the scope of standard use cases

Lists of integers yield rational numbers:

Out[1]=1

Lists of approximate numbers yield approximate numbers:

Out[2]=2

Moving averages of matrices are matrices:

Out[1]=1
Out[2]=2
Out[3]=3

Obtain results for lists of any precision:

Out[1]=1

Obtain results for weights of any precision:

Out[1]=1

Filter large datasets:

Out[3]=3

Generalizations & Extensions  (4)Generalized and extended use cases

Compute results for a SparseArray:

Out[1]=1
Out[2]=2
Out[3]=3

A moving average of TemporalData places the result on the right end of the moving windows:

Out[1]=1

Incomplete windows are dropped:

Out[2]=2
Out[3]=3

The values of a moving average of TemporalData are equivalent to the moving average of its values:

Out[1]=1
Out[2]=2
Out[3]=3
Out[4]=4
Out[5]=5

The results of a moving average of TemporalData are placed on the right end of the window, and the windows with the smaller number of observations then requested are dropped:

Out[6]=6
Out[7]=7

The moving average of a numeric TimeSeries for various window lengths:

Incomplete windows are dropped, and the result is placed on the right end of each window:

Out[5]=5

Applications  (2)Sample problems that can be solved with this function

Smooth noisy data:

Out[1]=1
Out[2]=2
Out[3]=3
Out[4]=4

Compute the 100-day moving average of a financial time series:

Out[1]=1
Out[2]=2

Properties & Relations  (7)Properties of the function, and connections to other functions

A moving average is a sequence of means:

Out[1]=1
Out[2]=2

A twoterm MovingAverage is equivalent to a twoterm MovingMedian:

Out[1]=1
Out[2]=2

MovingAverage is equivalent to MovingMap of Mean:

Out[2]=2
Out[3]=3
Out[4]=4

An nterm moving average is equivalent to a moving average with n equal weights:

Out[2]=2
Out[3]=3

An nterm moving average is equivalent to a ListCorrelate:

Out[1]=1
Out[2]=2

An nterm weighted moving average is equivalent to a ListCorrelate:

Out[1]=1
Out[2]=2

Multiplying weights by a constant gives the same moving average:

Out[2]=2
Wolfram Research (2007), MovingAverage, Wolfram Language function, https://reference.wolfram.com/language/ref/MovingAverage.html.
Wolfram Research (2007), MovingAverage, Wolfram Language function, https://reference.wolfram.com/language/ref/MovingAverage.html.

Text

Wolfram Research (2007), MovingAverage, Wolfram Language function, https://reference.wolfram.com/language/ref/MovingAverage.html.

Wolfram Research (2007), MovingAverage, Wolfram Language function, https://reference.wolfram.com/language/ref/MovingAverage.html.

CMS

Wolfram Language. 2007. "MovingAverage." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/MovingAverage.html.

Wolfram Language. 2007. "MovingAverage." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/MovingAverage.html.

APA

Wolfram Language. (2007). MovingAverage. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/MovingAverage.html

Wolfram Language. (2007). MovingAverage. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/MovingAverage.html

BibTeX

@misc{reference.wolfram_2025_movingaverage, author="Wolfram Research", title="{MovingAverage}", year="2007", howpublished="\url{https://reference.wolfram.com/language/ref/MovingAverage.html}", note=[Accessed: 12-May-2025 ]}

@misc{reference.wolfram_2025_movingaverage, author="Wolfram Research", title="{MovingAverage}", year="2007", howpublished="\url{https://reference.wolfram.com/language/ref/MovingAverage.html}", note=[Accessed: 12-May-2025 ]}

BibLaTeX

@online{reference.wolfram_2025_movingaverage, organization={Wolfram Research}, title={MovingAverage}, year={2007}, url={https://reference.wolfram.com/language/ref/MovingAverage.html}, note=[Accessed: 12-May-2025 ]}

@online{reference.wolfram_2025_movingaverage, organization={Wolfram Research}, title={MovingAverage}, year={2007}, url={https://reference.wolfram.com/language/ref/MovingAverage.html}, note=[Accessed: 12-May-2025 ]}