# Work with Irregular Time Series

Draw a sample of Poisson process, sampled at the random times of arrivals.

 In[1]:= Xpoi = PoissonProcess[1.2]; data = TimeSeries[RandomFunction[poi, {0, 100}]]
 Out[1]=
 In[2]:= XRegularlySampledQ[data]
 Out[2]=

Visualize the time series.

 In[3]:= XListPlot[data, Filling -> Axis, ImageSize -> 300]
 Out[3]=

Use TimeSeriesMapThread to subtract the mean function from the time series.

 In[4]:= Xmf[t_] = Mean[poi[t]]; cdata = TimeSeriesMapThread[Function[{t, x}, x - mf[t]], data];
 In[5]:= XListPlot[cdata, Filling -> Axis, ImageSize -> 300]
 Out[5]=

Use MovingMap to compute mean over a centered constantwidth sliding window.

 In[6]:= Xmts = MovingMap[Mean, cdata, {10, Center}, "Reflected"];
 Out[7]=

Use TimeSeriesAggregate to build regularly spaced time series of the largest values in non-overlapping windows of constant width.

 In[8]:= Xadata = TimeSeriesAggregate[data, {10, Right}, Max];
 Out[9]=
 Out[10]=

Resample with a step of 10 using interpolation of order 0.

 In[11]:= Xrdata = TimeSeriesResample[data, 10, ResamplingMethod -> {"Interpolation", InterpolationOrder -> 0}];
 Out[12]=
 In[13]:= XRegularlySampledQ[rdata]
 Out[13]=

Treat the original time series as regularly sampled for use in functions that require such uniformly sampled input.

 In[14]:= Xregdata = TimeSeries[data, TemporalRegularity -> True]
 Out[14]=
 In[15]:= Xdata["Path"] == regdata["Path"]
 Out[15]=
 In[16]:= XRegularlySampledQ[regdata]
 Out[16]=

## Mathematica

Questions? Comments? Contact a Wolfram expert »