Topology of time series¶
This notebook explores how giotto-tda
can be used to gain insights
from time-varying data by using ideas from from dynamical systems and
persistent homology.
If you are looking at a static version of this notebook and would like to run its contents, head over to GitHub and download the source.
Useful references¶
Topological Methods for the Analysis of Data by Jose Perea
The sliding window notebooks from Chris Tralie’s TDALabs
Detection of gravitational waves using topological data analysis and convolutional neural network: An improved approach by Christopher Bresten and Jae-Hun Jung. We thank Christopher Bresten for sharing the code and data used in the article.
See also¶
Gravitational waves detection, where,following arXiv:1910.08245, the Takens embedding technique is shown to be effective for the detection of gravitational waves signals buried in background noise.
Topology in time series forecasting, in which the Takens embedding technique is used in time series forecasting tasks by using sliding windows.
Topological feature extraction using VietorisRipsPersistence and PersistenceEntropy for a quick introduction to general topological feature extraction in
giotto-tda
.
License: AGPLv3
From time series to time delay embeddings¶
The first step in analysing the topology of time series is to construct a time delay embedding or Takens embedding, named after Floris Takens who pioneered its use in the study of dynamical systems. A time delay embedding can be thought of as sliding a “window” of fixed size over a signal, with each window represented as a point in a (possibly) higher-dimensional space. A simple example is shown in the animation below, where pairs of points in a 1-dimensional signal are mapped to coordinates in a 2-dimensional embedding space.

A 2-dimensional time delay embedding¶
More formally, given a time series \(f(t)\), one can extract a sequence of vectors of the form \(f_i = [f(t_i), f(t_i + \tau), f(t_i + 2 \tau), \ldots, f(t_i + (d-1) \tau)] \in \mathbb{R}^{d}\), where \(d\) is the embedding dimension and \(\tau\) is the time delay. The quantity \((d-1)\tau\) is known as the “window size” and the difference between \(t_{i+1}\) and \(t_i\) is called the stride. In other words, the time delay embedding of \(f\) with parameters \((d,\tau)\) is the function
and the main idea we will explore in this notebook is that if \(f\) has a non-trivial recurrent structure, then the image of \(TD_{d,\tau}f\) will have non-trivial topology for appropriate choices of \((d, \tau)\).
A periodic example¶
As a warm-up, recall that a function is periodic with period \(T > 0\) if \(f(t + T) = f(t)\) for all \(t \in \mathbb{R}\). For example, consider the function \(f(t) = \cos(5 t)\) which can be visualised as follows:
import numpy as np
import plotly.graph_objects as go
x_periodic = np.linspace(0, 10, 1000)
y_periodic = np.cos(5 * x_periodic)
fig = go.Figure(data=go.Scatter(x=x_periodic, y=y_periodic))
fig.update_layout(xaxis_title="Timestamp", yaxis_title="Amplitude")
fig.show()