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 are times.
  • The data can be a list of values , a list of time-value pairs , a TimeSeries, EventSeries, or TemporalData.
  • A function f of a single argument gets applied to a list of values 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 allows control over both time and value as well as producing multiple values per window. »
  • The full window specification wspec is a triple , 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 are specified by wpos. With data time stamps , wpos can be one of the following:
  • Automaticuse data time stamps
    {τmin,τmax}use such that
    {Automatic,τmax}equivalent to
    {τmin,Automatic}equivalent to
    {τmin,τmax,dτ}use , , etc.
    {{τ1,,τm}}use explicit , , etc.
  • By default, the time stamps of the output are .
  • 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 or .
  • Window alignment align determines relative position of within the window. The possible settings include Right (default), Left, and Center.
  • Window specification 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
    "ReflectedDifferences"reflections of the differences between times
    "PeriodicDifferences"cyclically pad with steps
  • 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
Translate this page: