applies f to size w windows in the specified data.

uses windows specified by wspec.

pads data using padding.


  • MovingMap can be used for regularly spaced data and for irregularly spaced data.
  • In many contexts, the ti are times.
  • The data can be a list of values {x1,x2,}, a list of time-value pairs {{t1,x1},{t2,x2},}, a TimeSeries, EventSeries, or TemporalData.
  • A function f of a single argument gets applied to a list of values {xi,xi+1,} for each window. »
  • A pure function f can access values, times, boundary values, and boundary times for each window using the following arguments: »
  • #Values or #1data values within the window
    #Times or #2data times within the window
    #BoundaryValues or #3resampled values at window boundaries
    #BoundaryTimes or #4times at window boundaries
  • By default, f is expected to compute a single value for each window and the time is computed automatically. Using a function f that gives output as rules {τi,}{vi,} allows control over both time and value as well as producing multiple values per window. »
  • The full window specification wspec is a triple {size,align,wpos}, where wpos determines time positions of each window, and size and align specify overall size and alignment that applies to all windows relative to the window positions wpos. »
  • Window placements {τ1,,τm} are specified by wpos. With data time stamps {t1,,tn}, wpos can be one of the following:
  • Automaticuse data time stamps τi=ti
    {τmin,τmax}use τi=tk+i such that τmintk+iτmax
    {Automatic,τmax}equivalent to {t1,τmax}
    {τmin,Automatic}equivalent to {τmin,tn}
    {τmin,τmax,dτ}use τ1=τmin, τ2=τmin+dτ, etc.
    {{τ1,,τm}}use explicit τ1, τ2, etc.
  • By default, the time stamps of the output are {τ1,,τm}.
  • Window size can be given as the following:
  • wpositive number, taken to mean days
    Quantity[w,timeunit]duration w in units of timeunit
    Quantity[n,"Events"]events count n defines the window size
  • The window size may be varying in an absolute sense when referring to relative units such as "Month" or "Events".
  • Window alignment align determines relative position of τi within the window. The possible settings include Right (default), Left, and Center.
  • Window specification {size,align} is equivalent to {size,align,Automatic}.
  • Window specification size or {size} is equivalent to {size,Right,Automatic}.
  • Settings for padding include:
  • Automaticonly keep non-overhanging windows (default)
    Noneno padding, keep all windows
    valuepaddingequivalent to {Automatic,valuepadding}
    {timepadding,valuepadding}padding settings for times and values
  • Settings for valuepadding can be any valid specification recognized by ArrayPad.
  • Settings for timepadding include:
  • Automaticpad uniformly median time-step size
    Δtpad uniformly with step-size Δt
    {Δt1,Δt2,}cyclically pad with steps Δti
    "ReflectedDifferences"reflections of the differences between times
    "PeriodicDifferences"cyclically pad with steps ti+1-ti
  • MovingMap threads pathwise for multipath data.

ExamplesExamplesopen allclose all

Basic Examples  (3)Basic Examples  (3)

Perform average over window of length 2:

Click for copyable input

Perform a three-element moving average:

Click for copyable input

Smooth an irregularly spaced time series:

Click for copyable input
Click for copyable input
Click for copyable input

Place the window regularly with monthly intervals:

Click for copyable input

Smooth multiple paths simultaneously:

Click for copyable input

Use a centered window and reflected padding:

Click for copyable input
Click for copyable input
Introduced in 2014
| Updated in 2015