# How Does the Uncertainty Principle Limit Time Series Analysis? | by Rodrigo da Motta | Aug, 2023

## Why we can’t extract precise time and frequency information from a time series mutually, and how wavelet analysis can tackle this limitation

The connection between the Fourier Transform, Uncertainty Principle, and time series analysis unveils a fascinating interplay that shapes the extraction of simultaneous temporal and frequency information. To understand this relationship, it’s important to first briefly understand what a Fourier Transform (FT) and the uncertainty principle are as a consequence. Then, we explore Wavelet Transform (WT) as a promising tool for this limitation, revealing specific frequency temporal occurrences with sufficient clarity.

## 1.1 Fourier Transform

The Fourier Transform (FT) serves as a mathematical bridge between the time and frequency domains of a function. An FT can be described as:

I’m not going into detail in this integral, but the important part is that an FT transforms the function f(x) to another function g(ω) in the frequency space. Hold that information for later, it’s going to be important. (To better understand the FT I highly recommend the video from 3Blue1Brow.)

## 1.2 Uncertainty Principle as a Consequence of Fourier Transform

In 1927 physicist Werner Heisenberg introduced what is probably one of the most famous concepts about quantum mechanics, the uncertainty principle [1]. The principle is basically a theorem about Fourier Transforms, when two functions are a Fourier Transform of one another, the uncertainty principle comes into play.

While we momentarily sidestep its intricate physics, consider just the essence: the product of uncertainties in position x and momentum p remains bounded. This limitation underscores the inherent boundary in measuring these quantities with infinite precision (if you’re interested check out this video).

This happens because position and momentum are a Fourier Transform of each other! In the case of time series analysis, the analogue of position x and momentum p is the time series in temporal t and frequency ω space, respectively.

A very important application of the Fourier Transform is in time series analysis. Consider a scenario where we need to find the inherent frequencies in the time series. For instance, think about discerning the prevalent frequencies that people re-watch a given content. Therefore, we want to transform f(t) (a time series) into g(ω), a function of the frequencies, using an FT.

## 2.1 Example

To exemplify let’s use the Mauna Loa Weekly Atmospheric CO2 Dataset [2].

Removing the linear trend to remove fake low-frequency contributions:

Using the Fast Fourier Transform algorithm (FFT) to calculate the FT:

Whence, it’s possible to obtain the frequency that composes the series, and in this case are visible two distinct peaks, one yearly and the other half-yearly. This is a visualization of the clear seasonality of the dataset.

However, the most interesting aspects happen when there is a perturbation in the time series, which could be the impact of an event or an external variable (e.g. a near volcano eruption). To simulate this we can take the same series plus a stochastic sine addition:

Applying the FFT to get the FT of the series:

Now, there is another set of peaks between 0.5 and 0.75 that is caused by the perturbation.

## 2.2 The limitation

At times, we want to know when the perturbation and frequency change happened, or simply the temporal placement of each frequency within the series. In our simulation o the series with and without perturbation, it’s clear that most of the impact is at the beginning of the series. Yet, a visual inspection of the series combined with FT information is not enough to know where that perturbation happened. Therefore, we need to find another tool to help us.

However, the Fourier Transform (FT) comes with a trade-off: it strips away temporal information as the uncertainty principle shows, rendering us unaware of when these frequencies manifest in the series. This is where the uncertainty principle steps in. Instead of pursuing infinite accuracy in either frequency or time, we can harness the uncertainty principle, allowing us to gain insights into both quantities at a reduced resolution, all the while maintaining balance.

The Wavelet Transform (WT) emerges as a resolution balancing act, which transforms our function f(t) in F(t,ω), a composition of time and frequency. I’m not going into detail about how WT works, but, to summarize, the transformation process uses a series of different wavelets (signals with known frequency and shape) to match temporal synchronization with the time series by dot products of two functions. Hence, it’s possible to get a sense of the frequency and temporal occurrence but limited by less resolution in both quantities.

To visualize the wavelet transform of a signal, it’s common to represent the x-axis as the time scale and y-axis as the frequency scale, and the colour scale as the Power of the frequency.

For the detrended time series without perturbation,

it’s possible to see clearly that the seasonality repeats over the years as we expected by visual inspection. But the huge peak of 1-year seasonality from the FT is now wider, so our certainty about the value decreased.

The most interesting analysis is for the simulated scenario.

The WT show that the lower frequency perturbation observed in the FT happens in the early years of the series, with significant consequences after 20–25 years. Even though the WT lose resolution both in time and frequency, the new information about the frequency occurrence is valuable and capable of answering a variety of questions.

In short, the Uncertainty Principle imposes a fundamental limitation on time series analysis, as revealed by the constraints of the Fourier Transform. While the Fourier Transform efficiently extracts frequency information from time series data, it sacrifices any knowledge of when those frequencies occur. Therefore, the Wavelet Transform is a useful tool that enables us to trade off time and frequency resolution to gain insights into the temporal occurrence of frequency components accepting a degree of uncertainty inherent to the principle.