Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Remove redundant data from a time series
ResourceFunction["TimeSeriesCompress"][tseries] compresses time series tseries by removing data points that can be accurately predicted through linear interpolation. |
| "ValueTolerance" | 10-10 | maximal allowed value deviation with respect to the original value |
| "MaxTimeDistance" | Infinity | maximal allowed time distance between two data points |
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]= | ![]() |
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]= | ![]() |
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]= |
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]= |
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]= |
This work is licensed under a Creative Commons Attribution 4.0 International License