Fourier Transform
General Definition of the Fourier Transform
In general, the Fourier transform describes a mathematical procedure that decomposes a signal into its frequency components. A signal is a sequence of measured values, which in the context of forecasting usually represents a time series, for example describing daily sales figures or hourly electricity loads. The Fourier transform maps the signal from the time domain to the frequency domain. The time domain represents the classic visualization of time series data, with time/date on the x-axis and the measured value on the y-axis. In the frequency domain, the axis labels change. The horizontal axis describes the frequency (how often something occurs per time unit), while the vertical axis indicates how strongly that specific frequency is represented in the signal (amplitude). A peak in the frequency domain thus shows how often a certain pattern repeats per observed time unit (e.g., per year). The goal of this transformation is to expose hidden information in a complex signal, such as periodically recurring patterns in the form of seasonality. Furthermore, different types of Fourier transforms can be distinguished. In general, one refers to the continuous Fourier transform, which transforms continuous functions that can consist of an infinite number of infinitesimal frequencies. Since time series consist of a finite, countable number of values, the discrete Fourier transform is used here. It transforms the time series only into frequencies that can actually be present (as explained further below).
Fourier Transform in Forecasting
Data in the Time Domain
Time series usually reflect real-world data and often contain noisy patterns that are not immediately obvious. To investigate arbitrary time series for recurring patterns despite this noise, the Fourier transform serves as a powerful tool. It transforms the time series from its natural representation into a representation in the frequency domain.
Based on this time series, an annual seasonality can already be suspected. However, whether additional seasonalities exist is difficult to identify at first glance.
Data in the Frequency Domain
By applying the Fourier transform (in this case, the discrete Fourier transform), the time series is transformed from the time domain to the frequency domain. In the frequency domain, the individual data values are no longer visible. Instead, it reveals how frequently patterns occur per time unit. By identifying frequencies with high amplitudes in the Fourier-transformed time series, different seasonal patterns can be identified.
In this example, two frequencies clearly stand out. These frequencies indicate that certain patterns in the time series repeat once per year and 52 times per year, respectively. The annual repetition reflects yearly seasonality, while the 52-fold annual repetition points to a weekly seasonality, since a year consists of approximately 52 weeks.
Seasonalities of the Data
The frequencies identified in the frequency domain of the time series can now be translated into seasonal components of the data. The first frequency with a high amplitude indicates a sine wave with a large amplitude that completes one full cycle per year (or two cycles over a two-year period).
The second frequency, whose peak is lower than that of the first frequency, indicates a sine wave with a smaller amplitude, which completes 52 cycles per year (or 13 cycles over 3 months), as made visible in the zoomed-in section below.
How the Fourier Transform Works
The Fourier transform is based on the fact that any periodic function can be composed of sine and cosine waves. During the transformation, the overall signal (in this case, the time series) is compared with every theoretically available sine and cosine wave. Here, the signal is multiplied by a specific test frequency, and the average over the entire duration is calculated using an integral. There are two possible outcomes for each test frequency:
- The test frequency is not present in the signal. Here, the sine/cosine waves of the signal run asynchronously to the waves of the test frequency. This produces both positive and negative values during multiplication, which cancel each other out over the total duration (destructive interference). Consequently, this frequency will have a value close to zero in the frequency domain.
- The test frequency is present in the signal. The test-frequency wave oscillates at the same rhythm as a hidden component in the signal. As a result, the values systematically reinforce each other during multiplication (constructive interference). In the frequency domain, this produces a clearly recognizable peak.
Since a signal is defined not only by how fast it oscillates, but also by wave height (amplitude) and starting point (shift along the time axis), this information must be captured simultaneously. To achieve this, the Fourier transform utilizes complex numbers, representing test frequencies as vectors in a two-dimensional space. The length of the vector indicates how strongly the frequency is represented in the signal (amplitude). The angle of the vector contains information about the shift along the time axis (phase). In the Fourier transform, these tests are performed for all frequencies. The final result is a continuous function (spectrum), where each frequency (position on the x-axis) has an assigned strength (amplitude: height of the point on the y-axis). Because this is a linear process (and therefore reversible), no information is lost. Only the basis is transformed, expressing the same information in frequency units instead of time units.
Discrete Fourier Transform
In time series analysis, data is available in discrete form—whether on an hourly, daily, weekly, or other time-unit basis. To detect frequencies in such data, the discrete Fourier transform (DFT) is applied. The key difference compared to the continuous Fourier transform lies in the existence of a lower and upper frequency bound, with the steps between these bounds chosen specifically. The lower bound of the test frequencies is the frequency spanning the entire observed period (e.g., 1 time per year for annual data). The upper bound, on the other hand, is given by the fastest observable oscillation in the respective scenario. For instance, with daily data, the fastest observable oscillation is a two-day cycle (high on the first day, low on the second day). The intermediate test frequencies are selected in integer steps between the lower and upper bounds. This ensures that only frequencies that can actually occur in the given time series are evaluated.