({{, (RefLink[MovingMap, paclet:ref/MovingMap])[f,data,w]
applies f to size w windows in the specified data.}, {, (RefLink[MovingMap, paclet:ref/MovingMap])[f,data,wspec]
uses windows specified by wspec.}, {, (RefLink[MovingMap, paclet:ref/MovingMap])[f,data,wspec,padding]
pads data using padding.}})

OpenersNotesSection(Spacer1)Details

(RefLink[MovingMap, paclet:ref/MovingMap]) can be used for regularly spaced data and for irregularly spaced data.

In many contexts, the (Subscript[t, i]) are times.

The data can be a list of values {(Subscript[x, 1]),(Subscript[x, 2]),…}, a list of time-value pairs {{(Subscript[t, 1]),(Subscript[x, 1])},{(Subscript[t, 2]),(Subscript[x, 2])},…}, a (RefLink[TimeSeries, paclet:ref/TimeSeries]), (RefLink[EventSeries, paclet:ref/EventSeries]), or (RefLink[TemporalData, paclet:ref/TemporalData]).

A function f of a single argument gets applied to a list of values {(Subscript[x, i]),(Subscript[x, i+1]),…} for each window. »

A pure function f can access values, times, boundary values, and boundary times for each window using the following arguments: »

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 {(Subscript[τ, i]),…}->{(Subscript[v, i]),…} 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 {(Subscript[τ, 1]),…,(Subscript[τ, m])} are specified by wpos. With data time stamps {(Subscript[t, 1]),…,(Subscript[t, n])}, wpos can be one of the following:

By default, the time stamps of the output are {(Subscript[τ, 1]),…,(Subscript[τ, m])}.

Window size can be given as the following:

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 (Subscript[τ, i]) within the window. The possible settings include (RefLink[Right, paclet:ref/Right]) (default), (RefLink[Left, paclet:ref/Left]), and (RefLink[Center, paclet:ref/Center]).

Window specification {size,align} is equivalent to {size,align,(RefLink[Automatic, paclet:ref/Automatic])}.

Window specification size or {size} is equivalent to {size,(RefLink[Right, paclet:ref/Right]),(RefLink[Automatic, paclet:ref/Automatic])}.

Settings for padding include:

Settings for valuepadding can be any valid specification recognized by (RefLink[ArrayPad, paclet:ref/ArrayPad]).

Settings for timepadding include:

(RefLink[MovingMap, paclet:ref/MovingMap]) threads pathwise for multipath data.

OpenersPrimaryExamplesSection(Spacer1)Examples  (50)

OpenersExampleSection0(Spacer1)Basic Examples  (3)

Perform average over window of length 2:

MovingMap[Mean,{(Subscript[x, 1]),(Subscript[x, 2]),(Subscript[x, 3]),(Subscript[x, 4]),(Subscript[x, 5])},2]

Perform a three-element moving average:

MovingMap[Mean,{(Subscript[x, 1]),(Subscript[x, 2]),(Subscript[x, 3]),(Subscript[x, 4]),(Subscript[x, 5])},Quantity[3,"Events"]]

Smooth an irregularly spaced time series:

data=TimeSeries[FinancialData["AAPL",{"2000","2015"}]];

med=MovingMap[Median,data,Quantity[3,"Months"]]

Show[DateListLogPlot[data,PlotStyle->GrayLevel[.7]],DateListLogPlot[med,Joined->True,PlotStyle->Thick]]

Place the window regularly with monthly intervals:

med=MovingMap[Median,data,{{3,"Month"},Right,"Month"}]

Smooth multiple paths simultaneously:

data=RandomFunction[BrownianBridgeProcess[{0,-1},{2,1}],{0,2,.01},3];

Use a centered window and reflected padding:

avg=MovingMap[Mean,data,{0.1,Center},"Reflected"];

Show[ListPlot[data],ListLinePlot[avg]]

OpenersExampleSection1(Spacer1)Scope  (30)

OpenersExampleSubsection0(Spacer1)Basic Uses  (4)

Map a function f over data with a window of width two units of time:

data={{1,(Subscript[x, 1])},{2,(Subscript[x, 2])},{4,(Subscript[x, 4])},{6,(Subscript[x, 6])},{7,(Subscript[x, 7])},{12,(Subscript[x, 12])}};

MovingMap[f,data,2]

Map a function f over data with a three-events window:

MovingMap[f,data,Quantity[3,"Events"]]

Compute a moving quantile for some data:

data=RandomFunction[WienerProcess[],{0,10,0.1}];

Use centered window of unit size:

mq=MovingMap[Quantile[#,0.75]&,data,{1,Center}];

ListLinePlot[{data,mq}]

Find a moving quartile envelope:

data=TimeSeries[Accumulate[RandomReal[{-1,1},250]],{1}];

q=MovingMap[Quartiles,data,{12,Center}]

ListLinePlot[q]

Find a yearly moving average of SP500 time series:

sp500ts=TimeSeries[FinancialData["SP500",{"2000", "2015"}]]

MovingMap[Mean,sp500ts,"Year"]

Find a yearly moving average of the time series, placing windows monthly:

MovingMap[Mean,sp500ts,{"Year",Right,"Month"}]

Place windows monthly at the first day of each month and use reflected value padding:

sp500smoothed=MovingMap[Mean,sp500ts,{"Year",Right,{"Jan 1 2001",Automatic,"Month"}},"Reflected"]

DateListPlot[{sp500ts,sp500smoothed},Joined->{False,True},PlotStyle->{PointSize[Tiny],Automatic,Automatic}]

OpenersExampleSubsection1(Spacer1)Data Types  (7)

Create a generic moving function for a vector:

v=Table[(Subscript[x, t]),{t,1,12}]

MovingMap[f,v,2]

Compute a moving average for a list of time-value pairs:

data={{"2005",1},{"2006",-1},{"2007",3},{"2008",6},{"2009",-2},{"2010",4},{"2011",5},{"2012",4},{"2013",6},{"2014",3}};

mavg=MovingMap[Mean,data,"Year"];

DateListPlot[{data,mavg},Joined->True]

Compute a moving (RefLink[GeometricMean, paclet:ref/GeometricMean]) for a (RefLink[TimeSeries, paclet:ref/TimeSeries]):

ts=TimeSeries[];

mmx=MovingMap[GeometricMean,ts,5,None];

ListLinePlot[{ts,mmx}]

Compute a moving median for a (RefLink[TemporalData, paclet:ref/TemporalData]):

td=RandomFunction[ARMAProcess[{5/6},{1/2},1],{0,100}]

mmed=MovingMap[Median,td,10,None]

ListLinePlot[{td,mmed}]

Compute a moving total for an (RefLink[EventSeries, paclet:ref/EventSeries]):

es=EventSeries[];

tot=MovingMap[Total,es,10];

ListPlot[{tot,es},Filling->2->Axis,Joined->{True,False},InterpolationOrder->0]

Compute a moving variance for multiple paths simultaneously:

td=RandomFunction[BrownianBridgeProcess[],{0,1,.01},3];

mvar=MovingMap[Variance,td,0.15];

ListLinePlot[mvar,PlotRange->All]

Compute a moving correlation coefficient between two components of a bivariate time series:

α={{.2,.1},{-.3,.2}};
Σ={{1,0.3},{0.3,.3}};
ar=RandomFunction[ARProcess[{α},Σ],{1,5000}];

Moving correlation coefficient over window of size 100:

corFunc=Apply[Correlation,Transpose[#]]&;
rng=MovingMap[corFunc,ar,100];

ListLinePlot[rng]

OpenersExampleSubsection2(Spacer1)Functions  (5)

Apply a generic function to values within moving windows:

data={{0.2,(Subscript[x, 1])},{0.5,(Subscript[x, 2])},{0.7,(Subscript[x, 3])},{1,(Subscript[x, 4])},{1.1,(Subscript[x, 5])},{1.3,(Subscript[x, 6])}};

MovingMap[f,data,0.6]

Use a pure function instead:

MovingMap[f[#1]&,data,0.6]

MovingMap[f[#Values]&,data,0.6]

Apply a generic function to values and time stamps within moving windows:

data={{2,(Subscript[x, 1])},{5,(Subscript[x, 2])},{7,(Subscript[x, 3])},{10,(Subscript[x, 4])},{11,(Subscript[x, 5])},{13,(Subscript[x, 6])}};

MovingMap[f[#1,#2]&,data,6]

Use a pure function with named arguments:

MovingMap[f[#Values,#Times]&,data,6]

Also provide the function with boundary times and resampled values of data at boundary times:

MovingMap[f[#Values,#Times,#BoundaryTimes,#BoundaryValues]&,TimeSeries[data],6]//Normal

Define a function to compute both times and values for each window:

f[vals_,{bt1_,bt2_},q_]:={q bt1+(1-q)bt2}->{Mean[vals]}

Use it to effectively associate window average with scaled time point within the window:

ts=TimeSeries[Accumulate[RandomReal[{-1,1},21]],{0,Automatic,0.1}]

Table[MovingMap[f[#Values,#BoundaryTimes,q]&,ts,0.5],{q,{0,1/4,1/2,3/4,1}}]//ListLinePlot

Define a function that drops missing values and their corresponding times:

f[vals_,tms_]:=With[{ord=Position[vals,_Missing]},Delete[tms,ord]->Delete[vals,ord]]

Temperature readings in Champaign, IL:

temp=WeatherData["Champaign","Temperature",{"Jan 1 2015","Jan 31 2015"}]

Time series contains some missing values:

Mean[temp]

Delete data points with missing values:

wsize=Quantity[temp["PathLength"],"Events"];
cleanTemp=MovingMap[f[#1,#2]&,temp,wsize]

Compute the mean temperature in January:

Mean[cleanTemp]

Find the number of days between consecutive Thanksgiving holidays:

es=EventSeries[Range[1990,2010,1],{Table[WolframAlpha["thanksgiving date "~~ToString[y],{{"Result",1},"ComputableData"}],{y,1990,2010}]}]

res=MovingMap[DateDifference@@(#Dates)&,es,Quantity[2,"Events"]]

DateListPlot[res,Joined->False,Filling->Axis]

OpenersExampleSubsection3(Spacer1)Window Sizes  (4)

Use numeric width of the moving window:

ts=TimeSeries[{(Subscript[x, 1]),(Subscript[x, 2]),(Subscript[x, 3]),(Subscript[x, 4]),(Subscript[x, 5]),(Subscript[x, 6]),(Subscript[x, 7]),(Subscript[x, 8]),(Subscript[x, 9])},{1}];

MovingMap[f,ts,2]//Normal

Use time quantities to specify extent of the moving window:

data=TimeSeries[FinancialData["APPLX","2010"]];

mvar=MovingMap[GeometricMean,data,Quantity[2,"Quarters"]]

DateListPlot[{data,mvar},Joined->True]

Specify window size using pairs {n,"unit"}:

windowSize={1,"Day"};
winter=WeatherData["Chicago","Temperature",{"Dec 2013","Feb 2014"}];
tempTS=TimeSeries[winter,MissingDataMethod->"PathMean"]

Find daily median temperature every 4 hours:

dmed=MovingMap[Median,tempTS,{windowSize,Right,{4,"Hour"}}]

Visualize the time series, showing seasonal temperature quartiles:

DateListPlot[dmed,FrameLabel->Automatic,GridLines->{Automatic,Quartiles[tempTS]}]

Specify window size by the number of events it contains:

windowSize=Quantity[3,"Events"];
es=EventSeries[Table[1,{52}],{RandomSample[DayRange["Jan 1 2014","Dec 31 2014"],52]}];

Find moving average number of events per week:

eventsPerWeek[times_]:=Length[times]/(DateObject[Last[times]]-DateObject[First[times]]);

MovingMap[eventsPerWeek[#Times]&,es,windowSize]

DateListPlot[%,PlotRange->All,TargetUnits->(1/"Weeks"),FrameLabel->Automatic]

OpenersExampleSubsection4(Spacer1)Window Alignment  (4)

Right-aligned windows use past values:

data=TimeSeries[{(Subscript[x, 1]),(Subscript[x, 2]),(Subscript[x, 3]),(Subscript[x, 4]),(Subscript[x, 5])},{1}];

MovingMap[f,data,{2,Right}]["Path"]

Right alignment is used by default:

MovingMap[f,data,{2}]["Path"]

Centered windows use both past and future values:

data=TimeSeries[{(Subscript[x, 1]),(Subscript[x, 2]),(Subscript[x, 3]),(Subscript[x, 4]),(Subscript[x, 5])},{1}];

MovingMap[f,data,{2,Center}]["Path"]

Left-aligned windows use future values:

data=TimeSeries[{(Subscript[x, 1]),(Subscript[x, 2]),(Subscript[x, 3]),(Subscript[x, 4]),(Subscript[x, 5])},{1}];

MovingMap[f,data,{2,Left}]["Path"]

Compare window alignments:

ts=TimeSeries[Accumulate[RandomReal[{-1,1},100]],{1}];

mavg=MovingMap[Mean,ts,{20 MinimumTimeIncrement[ts],#}]&/@{Right,Center,Left};

Because the time series is regular, values of moving averages for each alignment are equal:

Equal@@(#["Values"]&/@mavg)

The times are not:

Equal@@(#["Times"]&/@mavg)

A visual comparison:

Show[ListPlot[ts,PlotStyle->Gray],ListLinePlot[mavg,PlotStyle->Thick,PlotLegends->{Right,Center,Left}]]

OpenersExampleSubsection5(Spacer1)Window Placements  (3)

Place windows automatically at every data point:

MovingMap[f,Table[{t,(Subscript[x, t])},{t,9}],{3,Right,Automatic}]

Place windows at every data point within an interval:

MovingMap[f,Table[{t,(Subscript[x, t])},{t,9}],{3,Right,{5,8}}]

Place windows at every data point after a given instant:

MovingMap[f,Table[{t,(Subscript[x, t])},{t,9}],{3,Right,{6.5,Automatic}}]

Place windows uniformly:

path=RandomFunction[PoissonProcess[$VersionNumber],{0,25}]

MovingMap[Last,path,{2,Right,1},"Fixed"]

Place windows uniformly within a given range:

MovingMap[Last,path,{2,Right,{0.5,24.5,1}},"Fixed"]

Place windows at the given time stamps:

cat=TimeSeries[FinancialData["CAT",{"2010","2015"}]]

wpos={{(DateObject["Sat 13 Nov 2010", DateObject[{2010,11,13}]]),(DateObject["Tue 5 Apr 2011", DateObject[{2011,4,5}]]),(DateObject["Sun 16 Dec 2012", DateObject[{2012,12,16}]]),(DateObject["Thu 24 Apr 2014", DateObject[{2014,4,24}]]),(DateObject["Wed 14 May 2014", DateObject[{2014,5,14}]]),(DateObject["Thu 25 Sep 2014", DateObject[{2014,9,25}]])}};

Find the highest stock value within the last two quarters for each date of interest:

MovingMap[Max,cat,{{2,"Quarter"},Right,wpos}]

OpenersExampleSubsection6(Spacer1)Padding  (3)

With (RefLink[Automatic, paclet:ref/Automatic]) padding, only those windows that do not overhang the data time domain are used:

data={{0.,(Subscript[x, 0])},{0.7,(Subscript[x, 1])},{1.2,(Subscript[x, 2])},{1.5,(Subscript[x, 3])},{1.9,(Subscript[x, 5])},{2.35,(Subscript[x, 6])}};

mmR=MovingMap[f,data,{0.8,Right},Automatic]

mmL=MovingMap[f,data,{0.8,Left},Automatic]

mmC=MovingMap[f,data,{0.8,Center},Automatic]

(RefLink[Automatic, paclet:ref/Automatic]) padding is used by default:

MovingMap[f,data,1.7,Automatic]

MovingMap[f,data,1.7]

With padding set to (RefLink[None, paclet:ref/None]), some windows may overhang the data time domain:

data={{0.,(Subscript[x, 0])},{0.7,(Subscript[x, 1])},{1.2,(Subscript[x, 2])},{1.5,(Subscript[x, 3])},{1.9,(Subscript[x, 5])},{2.35,(Subscript[x, 6])}};

mmR=MovingMap[f,data,{0.8,Right,{0.2,1.7,.5}},None]

Use (RefLink[Automatic, paclet:ref/Automatic]) time padding and constant value padding:

MovingMap[f[#1,#2]&,{{0.,(Subscript[x, 0])},{0.7,(Subscript[x, 1])},{1.2,(Subscript[x, 2])},{1.5,(Subscript[x, 3])},{1.9,(Subscript[x, 5])},{2.35,(Subscript[x, 6])}},{1,Right},{Automatic,p}]

OpenersExampleSection3(Spacer1)Applications  (10)

OpenersExampleSubsection7(Spacer1)Smoothing and Thinning Data  (1)

Temperature readings in Savoy, IL, around Valentine's Day at about one-minute resolution:

temps=EventSeries[];

Compute the hourly moving average at resolution of 20 minutes:

ma=MovingMap[Mean,temps,{"Hour",Right,Quantity[20,"Minutes"]}]

DateListPlot[{temps,ma},PlotStyle->{Automatic,Thin}]

OpenersExampleSubsection8(Spacer1)Market Volatility  (1)

Identify periods of high volatility in the S&P 500:

data=TimeSeries[FinancialData["SP500",All]]

Five-year moving standard deviation:

smooth=MovingMap[StandardDeviation,data,{5*365,"Day"}];

DateListPlot[smooth,Joined->True,PlotStyle->Thick]

Annual moving interquartile range:

smooth=MovingMap[InterquartileRange,data,"Year"];

DateListPlot[smooth,Joined->True,PlotStyle->Thick]

Two-year moving range:

smooth=MovingMap[Max[#]-Min[#]&,data,{2,"Year"}];

DateListPlot[smooth,Joined->True,PlotStyle->Thick]

OpenersExampleSubsection9(Spacer1)Weighted Moving Average  (3)

Compute a moving average of a regular time series, assigning more weight to recent values:

data=TimeSeries[Accumulate@RandomReal[{-1,1},250]];

r=10;

wm=MovingMap[Mean[WeightedData[#,Range[r]]]&,data,Quantity[r,"Events"]];

ListPlot[{data,wm},Joined->{False,True}]

Compare to placing more weight on past values:

wmP=MovingMap[Mean[WeightedData[#,Range[r,1,-1]]]&,data,Quantity[r,"Events"]];

ListPlot[{data,wm,wmP},Joined->{False,True,True},PlotLegends->{None,"Recent","Past"},PlotStyle->{Brown,Automatic,Automatic},PlotTheme->"Detailed"]

Use a centered window, placing the most weight on central values:

data=TimeSeries[Accumulate[RandomReal[{-1,1},250]],{1}];

wFun[bw_]:=Table[HeavisideLambda[(x/(#))],{x,-#,#}]&[((bw-1)/2)]

ListPlot[wFun[11],Filling->Axis]

w=Range[5,75,15];

wm=Table[MovingMap[Mean[WeightedData[#,wFun[Length[#]]]]&,data,{bw,Center},"Reflected"],{bw,w}];

Show[ListPlot[data],ListLinePlot[wm,PlotLegends->w]]

Compute a moving-time average of irregularly sampled continuous-time series:

ts=TimeSeries[Table[{t,EllipticTheta[1,t,0.3]},{t,Join[{0.},RandomReal[{0,2Pi},254],{2.Pi}]}]]

Weights for the integral of a linear interpolation function over its domain:

timesToWeights[times_?VectorQ]:=ListConvolve[{1,1},Differences[ArrayPad[times,{1,1},"Fixed"]]]

Time average of linear interpolation of {{(Subscript[t, 1]),(Subscript[v, 1])},…,{(Subscript[t, n]),(Subscript[v, n])}} over the interval {(Subscript[t, 1]),(Subscript[t, n])}:

timeMean[vals_,tms_]:=Dot[vals,Normalize[timesToWeights[tms],Total]]

mm=MovingMap[timeMean[#Values,#Times]&,ts,{1.6,Right,{0.,2Pi,0.1}}]

int0[s_Real]:=NIntegrate[EllipticTheta[1,t,0.3],{t,s-1.6,s}]/1.6

Show[Plot[int0[s],{s,mm["FirstTime"],mm["LastTime"]},PlotStyle->Orange],ListPlot[mm,Filling->Axis]]

OpenersExampleSubsection10(Spacer1)Particle Trajectories  (2)

Simulate a trajectory with heavy-tailed measurement noise:

n[]:=RandomReal[CauchyDistribution[0,1]]

f[]:={u Cos[u]+n[],u Sin[u]+n[]};

data=Table[f[],{u,0,6π,1/100}];

The underlying signal and simulated path with noise:

{ParametricPlot[{u Cos[u],u Sin[u]},{u,0,6π}],pd=ListPlot[data,AspectRatio->1]}

Smooth the trajectory using a moving (RefLink[TrimmedMean, paclet:ref/TrimmedMean]):

td=TimeSeries[data,{0.,6π},ValueDimensions->2];

smooth[r_]:=MovingMap[TrimmedMean,td,{r,Center},"Reflected"]

Increasing the window size gives a smoother trajectory:

Table[ParametricPlot[Evaluate[smooth[r]["PathFunction"][t]],{t,0,6π}],{r,{.15,.25,.50,1}}]

Smooth an object's trajectory with measurement noise in 3D space:

n[]:=RandomReal[{-1,1}]

path=TimeSeries[Table[{Sin[u]+n[],Cos[u]+n[],u+n[]},{u,0,6Pi,.01}],Automatic];

ParametricPlot3D[path["PathFunction"][t],{t,0,1885},BoxRatios->1,PlotStyle->Thin]

smooth=MovingMap[Mean,path,{100,Center},"Reflected"];

ParametricPlot3D[smooth["PathFunction"][t],{t,0,1885},BoxRatios->1]

OpenersExampleSubsection11(Spacer1)GARCH and ARMA Processes  (1)

Compare the volatility of GARCH and ARMA processes:

g=GARCHProcess[.8,{.6},{.2}];

a=ARMAProcess[{.6},{.2},2];

The stationary mean and variance are equivalent for the processes:

Mean/@{g[t],a[t]}

Variance/@{g[t],a[t]}

garch=RandomFunction[g,{0,10^4}];
arma=RandomFunction[a,{0,10^4}];

For GARCH processes, the volatility exhibits characteristic spikes:

mvG=MovingMap[Variance,garch,100];
mvA=MovingMap[Variance,arma,100];

ListLinePlot[{mvG,mvA},PlotRange->All,PlotLegends->{"GARCH","ARMA"}]

OpenersExampleSubsection12(Spacer1)Time Series Filter  (1)

Minute-resolution temperature readings in Savoy, IL, around Valentine's Day:

temps=EventSeries[];

Specify a function to find the time and value of the highest temperature in the window:

maxTempFuncSpec=Function[{v,t},Module[{ord=Take[Ordering[v],-1]},t[[ord]]->v[[ord]]]];

Specify a function to find the time and value of the lowest temperature in the window:

minTempFuncSpec=Function[{v,t},Module[{ord=Take[Ordering[v],1]},t[[ord]]->v[[ord]]]];

Specifications for 1-day-long, left-aligned windows placed at the beginning of each day:

wSize=Quantity[1,"Day"];
wAlign=Left;
wPos={DateObject[{2015,2,10}],DateObject[{2015,2,17}],Quantity[1,"Day"]};

maxTS=MovingMap[maxTempFuncSpec,temps,{wSize,wAlign,wPos},None]

minTS=MovingMap[minTempFuncSpec,temps,{wSize,wAlign,wPos},None]

DateListPlot[{temps,maxTS,minTS},Joined->{True,False,False},Filling->{2->{Axis,ColorData[97,2]},3->{Axis,ColorData[97,3]}},PlotStyle->{Automatic,PointSize[Medium],PointSize[Medium]},GridLinesStyle->Dotted,GridLines->{AbsoluteTime/@DateRange[DayRound[#1,All],DayRound[#2,All,"Previous"],"Day"]&,None},Axes->True,PlotLegends->{"Temperature","Daily Max","Daily Min"},PlotTheme->"Detailed",ImageSize->Medium]

OpenersExampleSubsection13(Spacer1)Time-Changed Wiener Process  (1)

Build a sample of (RefLink[OrnsteinUhlenbeckProcess, paclet:ref/OrnsteinUhlenbeckProcess]) from a sample of (RefLink[WienerProcess, paclet:ref/WienerProcess]):

wp=RandomFunction[WienerProcess[],{0,2,0.01},5];

Using x(t)==μ+(x(0)-μ )exp(-θ t)+σ exp(-θ t) w((exp(2 θ t)-1)/(2 θ)), find x(t) and t from w(τ) and τ:

ouPoint[{w_},{τ_},{μ_,σ_,θ_,x0_}]:=Module[{t=(1/(2θ))Log[1+2 θ τ],α=(((1+2 θ τ))^(-1/2))},{t}->{μ+(x0-μ)α+σ α w}]

Compute a moving map over one event window, with a function that maps Wiener path time-value pair to Ornstein–Uhlenbeck path time-value pair:

oup=MovingMap[ouPoint[#1,#2,{1,0.3,5.3,2}]&,wp,Quantity[1,"Event"]];

Visualize simulated paths and compare to the process mean function:

mf[t_]=Mean[OrnsteinUhlenbeckProcess[1,0.3,5.3,2][t]]

Show[Plot[mf[t],{t,0,oup["MaximumTime"]},PlotStyle->{Black,Thin}],ListPlot[oup]]

OpenersExampleSection4(Spacer1)Properties & Relations  (5)

(RefLink[MovingMap, paclet:ref/MovingMap]) of (RefLink[Mean, paclet:ref/Mean]) over regular data is equivalent to (RefLink[MovingAverage, paclet:ref/MovingAverage]):

data={(Subscript[x, 1]),(Subscript[x, 2]),(Subscript[x, 3]),(Subscript[x, 4]),(Subscript[x, 5]),(Subscript[x, 6])};

MovingMap[Mean,data,Quantity[3,"Events"]]

MovingAverage[data,3]

%===%%

(RefLink[MovingMap, paclet:ref/MovingMap]) of (RefLink[Median, paclet:ref/Median]) over regular data is equivalent to (RefLink[MovingMedian, paclet:ref/MovingMedian]):

data=RandomInteger[{-10,10},10]

MovingMap[Median,data,Quantity[3,"Events"]]

MovingMedian[data,3]

%===%%

(RefLink[MovingMap, paclet:ref/MovingMap]) is related to (RefLink[ListConvolve, paclet:ref/ListConvolve]):

data={(Subscript[x, 1]),(Subscript[x, 2]),(Subscript[x, 3]),(Subscript[x, 4])};

r=3;

MovingMap[f,data,r-1,a]

ListConvolve[ConstantArray[1,r],data,{1,1},a,Times,f[{##}]&]

(RefLink[MovingMap, paclet:ref/MovingMap]) is related to (RefLink[ListCorrelate, paclet:ref/ListCorrelate]):

data={(Subscript[x, 1]),(Subscript[x, 2]),(Subscript[x, 3]),(Subscript[x, 4])};

r=3;

MovingMap[f,data,r-1,a]

ListCorrelate[ConstantArray[1,r],data,{-1,-1},a,Times,f[{##}]&]

Take successive differences:

data={(Subscript[x, 1]),(Subscript[x, 2]),(Subscript[x, 3]),(Subscript[x, 4]),(Subscript[x, 5]),(Subscript[x, 6]),(Subscript[x, 7])};

MovingMap[Last[#]-First[#]&,data,1]

Alternatively, use (RefLink[Differences, paclet:ref/Differences]):

Differences[data]

Generalize to higher-order differences:

diff[data_,r_:1]:=MovingMap[#1.((((-1))^(#1+Mod[r,2])) Binomial[r,#1]&)[Range[0,r]]&,data,r]

diff[data,2]

Table[diff[data,i]==Differences[data,i],{i,5}]

OpenersExampleSection5(Spacer1)Neat Examples  (2)

Find a moving global (RefLink[Min, paclet:ref/Min]) and (RefLink[Max, paclet:ref/Max]):

td=Table[u Cos[u],{u,0,16π,0.1}];

ListLinePlot[td]

Block[{absMax=-Infinity,absMin=Infinity},
max=MovingMap[(absMax=Max[absMax,Max[#]])&,td,1];
min=MovingMap[(absMin=Min[absMin,Min[#]])&,td,1];
]

ListLinePlot[{min,td,max},Filling->{1->{2}}]

Visualize the changing entropy in the US Constitution. Lower entropy occurs when the same words are used repeatedly:

constitution=StringSplit[ExampleData[{"Text","USConstitution"}],Except[WordCharacter]..];

ListLinePlot[MovingMap[Entropy,constitution,{200,Center}]]

There is a spike in entropy where several people list their names and states of origin:

constitution[[4501;;4607]]

The 25th Amendment, concerning presidential succession, is comparatively repetitive:

constitution[[7604;;7611]]

The top 10 most frequently occurring words in the 25th Amendment:

SortBy[Tally[constitution[[7604;;8015]]],Last][[-10;;]]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[MovingAverage, paclet:ref/MovingAverage])  ▪  (RefLink[TimeSeriesAggregate, paclet:ref/TimeSeriesAggregate])  ▪  (RefLink[TimeSeriesResample, paclet:ref/TimeSeriesResample])  ▪  (RefLink[TimeSeriesThread, paclet:ref/TimeSeriesThread])  ▪  (RefLink[RegularlySampledQ, paclet:ref/RegularlySampledQ])  ▪  (RefLink[MinimumTimeIncrement, paclet:ref/MinimumTimeIncrement])  ▪  (RefLink[TimeSeriesShift, paclet:ref/TimeSeriesShift])  ▪  (RefLink[TimeSeriesRescale, paclet:ref/TimeSeriesRescale])  ▪  (RefLink[TimeSeriesMap, paclet:ref/TimeSeriesMap])  ▪  (RefLink[TimeSeriesMapThread, paclet:ref/TimeSeriesMapThread])  ▪  (RefLink[TimeSeriesInsert, paclet:ref/TimeSeriesInsert])  ▪  (RefLink[TimeSeriesModelFit, paclet:ref/TimeSeriesModelFit])  ▪  (RefLink[TimeSeriesWindow, paclet:ref/TimeSeriesWindow])  ▪  (RefLink[TemporalData, paclet:ref/TemporalData])  ▪  (RefLink[TimeSeries, paclet:ref/TimeSeries])  ▪  (RefLink[EventSeries, paclet:ref/EventSeries])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Time Series Processing, paclet:guide/TimeSeries])}, {▪(RefLinkPlain[Data Transforms and Smoothing, paclet:guide/DataTransformsAndSmoothing])}, {▪(RefLinkPlain[Signal Processing, paclet:guide/SignalProcessing])}, {▪(RefLinkPlain[Date & Time, paclet:guide/DateAndTime])}})}})