- See Also
-
Related Guides
- Data Transforms and Smoothing
- Handling Arrays of Data
- Statistical Data Analysis
- Time Series Processes
- Financial & Economic Data
- Numerical Data
- Time Series Processing
- Linear and Nonlinear Filters
- Scientific Data Analysis
- Financial Computation
- Socioeconomic & Demographic Data
- Event Series Processing
- Signal Visualization & Analysis
- Signal Filtering & Filter Design
- Tech Notes
-
- See Also
-
Related Guides
- Data Transforms and Smoothing
- Handling Arrays of Data
- Statistical Data Analysis
- Time Series Processes
- Financial & Economic Data
- Numerical Data
- Time Series Processing
- Linear and Nonlinear Filters
- Scientific Data Analysis
- Financial Computation
- Socioeconomic & Demographic Data
- Event Series Processing
- Signal Visualization & Analysis
- Signal Filtering & Filter Design
- Tech Notes
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.
MovingAverage
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
- MovingAverage[list,r] gives a list of the means of elements in list taken in blocks of length r. »
- MovingAverage[list,wts] is equivalent to ListCorrelate[wts/Total[wts],list]. »
- MovingAverage handles both numerical and symbolic data.
- MovingAverage gives a list of length Length[list]-r+1.
- MovingAverage works with SparseArray, TimeSeries, and TemporalData objects. »
Examples
open all close allBasic Examples (2)
Scope (5)
Lists of integers yield rational numbers:
MovingAverage[{1, 5, 7, 3, 6, 2}, 3]Lists of approximate numbers yield approximate numbers:
MovingAverage[{1.2, 5.2, 3.4, 4.5, 2.3, 4.5}, 3]Moving averages of matrices are matrices:
data = RandomReal[5, {10, 2}]MovingAverage[data, 4]MovingAverage[data, {1 / 2, 1 / 3, 1 / 4, 1 / 5}]Obtain results for lists of any precision:
MovingAverage[N[{1, 5, 7, 3, 6, 2}, 25], 3]Obtain results for weights of any precision:
MovingAverage[{1, 5, 7, 3, 6, 2}, N[{1, 2, 3}, 30]]data = ConstantArray[1., 10 ^ 6] + RandomReal[{-0.1, 0.1}, 10 ^ 6];fdata = MovingAverage[data, 100];ListLinePlot[{data[[1 ;; 100]], fdata[[1 ;; 100]]}, PlotRange -> {0, 1.3}]Generalizations & Extensions (4)
Compute results for a SparseArray:
sp = SparseArray[{{i_, i_} :> i, {i_, j_} /; j == i + 1 :> i - 1}, {100, 10}]MovingAverage[sp, 5]MovingAverage[sp, {3, 2, 1, 5}]Compute the moving average of a numeric TimeSeries for various window lengths:
ts = TimeSeries[TimeEventSeries`TimestampData[Association["UniformlySpacedQ" -> True, "Count" -> 61,
"Endpoints" -> TabularColumn[Association["Data" -> {{0., 0.6}, {}, None},
"ElementType" -> "Real64"]], "MinimumTimeIncrement" -> 0.01]],
Ta ... 86436505, -0.344485981849591, -0.32017664131197604,
-0.339944678008272, -0.4962959466695484, -0.5235950374532581, -0.588853370532945,
-0.8359919314597413, -0.9675284674456728}, {}, None}, "ElementType" -> "Real64"]],
Association[]];wspec = {3, 7, 12};res = Table[MovingAverage[ts, k], {k, wspec}];Incomplete windows are dropped, and the result is placed on the right end of each window:
Tabular[Table[{wspec[[i]], res[[i]]["FirstTime"]}, {i, 3}], {"k", "first time"}]Show[ListPlot[ts, PlotStyle -> Gray], ListLinePlot[res, PlotLegends -> wspec]]A moving average of TemporalData places the result on the right end of the moving windows:
data = TemporalData[Array[a, {5}], {1, 5}]Incomplete windows are dropped:
MovingAverage[data, 3]%["Path"]The values of a moving average of TemporalData are equivalent to the moving average of its values:
vals = Table[Sqrt[i], {i, 1, 6}]td = TemporalData[vals]MovingAverage[td, 3]["Values"]MovingAverage[vals, 3]%% - %//SimplifyThe 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:
MovingAverage[td, 3]["Path"]ListPlot[{td, MovingAverage[td, 3]}, Joined -> {False, True}]Applications (2)
data = Range[20] + RandomReal[{-2, 2}, 20]smoothed = MovingAverage[data, 3]ListPlot[data]ListPlot[smoothed]Compute the 100-day moving average of a financial time series:
data = TimeSeries@FinancialData["GE", "Jan. 1, 2000"]DateListPlot[MovingAverage[data, 100]]Properties & Relations (7)
A moving average is a sequence of means:
MovingAverage[{a, b, c, d, e, f}, 3]Table[Mean[Take[{a, b, c, d, e, f}, {i, i + 2}]], {i, 4}]A two‐term MovingAverage is equivalent to a two‐term MovingMedian:
data = RandomReal[10, 10]MovingAverage[data, 2] == MovingMedian[data, 2]MovingAverage is equivalent to MovingMap of Mean:
data = {Subscript[x, 1], Subscript[x, 2], Subscript[x, 3], Subscript[x, 4], Subscript[x, 5], Subscript[x, 6]};MovingAverage[data, 3]MovingMap[Mean, data, Quantity[3, "Events"]]% === %%An n‐term moving average is equivalent to a moving average with n equal weights:
data = RandomReal[10, 10];MovingAverage[data, 3] == MovingAverage[data, {1, 1, 1}]MovingAverage[data, 3] == MovingAverage[data, {100, 100, 100}]An n‐term moving average is equivalent to a ListCorrelate:
data = RandomReal[10, 10]MovingAverage[data, 4] == ListCorrelate[Table[1 / 4, {4}], data]An n‐term weighted moving average is equivalent to a ListCorrelate:
data = RandomReal[10, 10]MovingAverage[data, {2, 3}] == ListCorrelate[{2, 3} / Total[{2, 3}], data]Multiplying weights by a constant gives the same moving average:
data = RandomReal[10, 10];MovingAverage[data, {1, 2, 3}] == MovingAverage[data, {1000, 2000, 3000}]See Also
Mean MovingMedian ExponentialMovingAverage Partition ListCorrelate Accumulate MovingMap
Function Repository: CumulativeAverages HampelFilter
Tech Notes
Related Guides
-
▪
- Data Transforms and Smoothing ▪
- Handling Arrays of Data ▪
- Statistical Data Analysis ▪
- Time Series Processes ▪
- Financial & Economic Data ▪
- Numerical Data ▪
- Time Series Processing ▪
- Linear and Nonlinear Filters ▪
- Scientific Data Analysis ▪
- Financial Computation ▪
- Socioeconomic & Demographic Data ▪
- Event Series Processing ▪
- Signal Visualization & Analysis ▪
- Signal Filtering & Filter Design
History
Text
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.
APA
Wolfram Language. (2007). MovingAverage. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/MovingAverage.html
BibTeX
@misc{reference.wolfram_2026_movingaverage, author="Wolfram Research", title="{MovingAverage}", year="2007", howpublished="\url{https://reference.wolfram.com/language/ref/MovingAverage.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_movingaverage, organization={Wolfram Research}, title={MovingAverage}, year={2007}, url={https://reference.wolfram.com/language/ref/MovingAverage.html}, note=[Accessed: 13-June-2026]}