Function Repository Resource:

# TimeSeriesCompress

Remove redundant data from a time series

Contributed by: Sascha Kratky
 ResourceFunction["TimeSeriesCompress"][tseries] compresses time series tseries by removing data points that can be accurately predicted through linear interpolation.

## Details and Options

ResourceFunction["TimeSeriesCompress"] is used to remove redundant data points from a time series. The resulting time series requires less memory, but behaves as the original series within given accuracy requirements.
The input tseries can be a list of values {x1,x2,}, a list of time-value pairs {{t1,x1},{t2,x2},}, a TimeSeries, an EventSeries or TemporalData.
If times are not given, then tseries is assumed to be regular with unit spacing.
ResourceFunction["TimeSeriesCompress"] uses a default tolerance for time series values of 10-10.
ResourceFunction["TimeSeriesCompress"] uses a maximal allowed time distance of ∞.
ResourceFunction["TimeSeriesCompress"] removes Missing data points as a side effect of compression.
ResourceFunction["TimeSeriesCompress"] takes the following options:
 "ValueTolerance" 10-10 maximal allowed value deviation with respect to the original value "MaxTimeDistance" Infinity maximal allowed time distance between two data points

## Examples

### Basic Examples (4)

Create an example time series:

 In[1]:=
 Out[1]=

Visualize the path:

 In[2]:=
 Out[2]=

Four redundant points are removed from the time series by compression:

 In[3]:=
 Out[3]=

Visualize the removed points:

 In[4]:=
 Out[4]=

### Scope (3)

Compress a list of numeric values:

 In[5]:=
 Out[5]=
 In[6]:=
 Out[6]=

Compress a list of time-value pairs:

 In[7]:=
 In[8]:=
 Out[8]=

Compressing TemporalData applies compression to all underlying paths. The resampling is changed to linear interpolation:

 In[9]:=
 Out[9]=

### Options (4)

Increasing the maximal allowed deviation in the time series value leads to better compression:

 In[10]:=
 Out[10]=
 In[11]:=
 Out[11]=

Visualize the removed points:

 In[12]:=
 Out[12]=

Backtesting the compressed time series values with the original time series values:

 In[13]:=
 Out[13]=

Limit the maximal time distance between two points:

 In[14]:=
 Out[14]=

### Possible Issues (3)

TimeSeriesCompress only works on time series whose values are scalars. Time series with higher-dimensional values are returned uncompressed:

 In[15]:=
 Out[15]=

EventSeries is a special case of TemporalData allowing no interpolation. To compress an EventSeries, convert it to a TimeSeries:

 In[16]:=
 Out[16]=

TimeSeriesCompress removes values with head Missing:

 In[17]:=
 Out[17]=
 In[18]:=
 Out[18]=

### Neat Examples (3)

Use TemporalData to store the stock prices of the FAANG companies since the beginning of the decade:

 In[19]:=
 Out[19]=

If you are not interested in cent fluctuations of the prices of these stocks, you can work with a compressed representation:

 In[20]:=
 Out[20]=

Compression reduces the required data points by about 40 percent:

 In[21]:=
 Out[21]=

Sascha Kratky

## Version History

• 1.0.0 – 07 October 2019