Nuts and Bolts of Fourier Transform for Time Series Forecasting — Python.

Balaji Muthukrishnan
4 min readFeb 10, 2019

Fourier transform is the basis for a lot of Engineering applications ranging from data processing to image processing and many more... Essentially this is a series that ‘I wish I had had access to during my college days’ to learn Fourier transform and its ubiquitous applications. To clearly understand the functioning of the Fourier transform, the focus is restricted to one specific application, the Time series forecasting. Even though there are various methods for time series forecasting like moving average, exponential smoothing, Arima, etc, I have chosen Fourier transform for this series. The reason for choosing Fourier transform is that it has lots of components involved and very less material available with forecasting intuition.

What is forecasting? Why is it important?

Forecasting is the process of predicting future events based on present and past events. One example is predicting the weather for next week depending on the weather of today, yesterday, last week, last month, etc. A second example is predicting the crop yield for next season depending on the crop yield of previous seasons. These general examples discussed above have a piece of subtle information about the common variable in both of them i.e. timestamp. Forecasting is totally dependent on date and time.

Forecasting is mainly used to solve the day to day problems in several business domains, we will try to understand the importance of forecasting by understanding the problem of the Apparel industry a part of Retail domain. The business pain of Apparel Industry — Increasing ROI(Return on Investment). The aim is to increase the revenue by a significant reduction in cost incurred for the total business process. This includes supply chain as well by accurately forecasting demand of all SKU for the next season, assuming we have the last 3 years sales data in month level granularity (In Apparel industry an SKU — Stock Keeping Unit might be a shirt or a pant or any clothing item. An year is divided in to two seasons - spring summer and autumn winter each comprising of six months).

What is a time series data?

Whenever the data is recorded at frequent intervals of time, it is a time series data. Time series data can be thought as,

  1. The univariate data with time as an index that creates an implicit order.
  2. The dataset having two variables, the independent variable — time and the dependent variable — Quantity of SKU sold during the last 36 months.

All the billing information captures date and time, the quantity of SKU sold and amount(sales) of Apparel stores, this type of data is time series data. Thus the forecasting problem of Apparel industry can be reduced to time series forecasting problem using Fourier transform.

What is a Fourier Transform?

Fourier transform is one of the best numerical computation of our lifetime, the equation of the Fourier transform is,

It is used to map signals from the time domain to the frequency domain. The reverse of it, Inverse Fourier transform is used to remap the signals from the frequency domain to the time domain.

courtesy:http://mriquestions.com

If you cannot appreciate these ideas right now, don’t worry, we will discuss these in detail throughout the series. The aim of this series is to give you an intuitive understanding of the Fourier transform, by understanding each component of the transform.

The series is organized as follows,

Part 1: What are imaginary numbers? Why do we need them?

Part 2: What is π? What’s its significance?

Part 3: What is e? Why is it important?

Part 4: Why combining e,π and i is a mathematical beauty?

Part 5: How Fourier transform works?

Part 6: How Inverse Fourier transform works?

Part 7: Implementation of Fourier transform in python for time series forecasting.

What will you accomplish?

After completing this series, you should be able to,

  1. Define time series problem and solve it using Fourier transform.
  2. Understanding the relationship between the time domain and the frequency domain.
  3. Why converting to the frequency domain makes sense for forecasting?
  4. How to set harmonics for Fourier transform?
  5. Appreciate the working of Fourier Transform.

Let us dive in…

Disclaimer: There are certain assumptions throughout the series, which will be stated then and there.

If you love to explore the nuances of Fourier transform, please go through the series. If you liked this series, please hit the clap button to recommend it to others.

--

--

Balaji Muthukrishnan

Data Scientist - Problem Solver, Statistics and Machine Learning practitioner.