Visualizing the Fourier Transform and Its Applications for Price Prediction

The Fourier transform (and Fourier transform visualization) is typically used to explore and process digital data, also known as discrete data, or sampled data, or a time series signal. In order to see how the Fourier transform can be applied to stock markets, we introduce some basic ideas about how the transform works.

This article contains some level of mathematical detail. You can skip some of these sections, and keep reading to find out about price prediction applications of this equation.

To jump directly to a section, click the table of contents:

Download the Full Fourier Transform Slide Deck (Additional Examples)

FREE DOWNLOAD

Send download link to:

Subscribe to the Insight Blog. Get notified when blogs, like this one, come out. You can unsubscribe anytime.

What is a Fourier Transform?

predictive analytics using fourier transform, frequency and time graph red purple blue

Above is an image showing a classic example of how the Fourier transform works.

  • the red wave represents the incoming signal
  • the purple waves show how the Fourier transform performs a fit to the data
  • the blue wave represents the transformed data output

So, the Fourier transform equation fits sines and cosines to the data to make an exact fit to the original data points.

In this simple Fourier transform example, the incoming red signal is unknown. However, after Fourier analysis, we get a clear description of the content of the data. In this visualization, the transformed blue result shows three periodic spikes, which clearly stand out from the random Gaussian noise under them.

The Fourier Transform Equation and Its Components

X(k) = sum x cos sin 2Pink fourier transform formula equation

For those interested in the mathematical formula of the Fourier transform, there it is.

Let’s see what happens when we set N to 10.

The Fourier transform equation creates a 10 by 10 matrix from the original data.

Fourier Transform as a Matrix

fourier transform matrix formulas, column 1 column 10
fourier transform angle matrix formula columns rows N=10

The Fourier transform equation also creates a set of angles, which are also 10 by 10, to be inserted into the Matrix. Each element in each column is distinct with its own angle measurement. Then, each matrix column is summed, giving 10 transformed values.

Each output value describes the energy of the “x” values in terms of frequency.

Fourier Transform Example: Vibration of a Car Engine

blue graph fourier transform, car engine idling example, time amplitude, frequency Hz FFT

In the top graph the signal looks complicated and random.

The bottom graph shows the Fourier analysis. We might expect to see the RPM of the engine idle, but in fact we see two distinct frequencies, one spike at 15 Hz (900 RPM) and a second large spike at 30 Hz (1800 RPM). The second spike occurs because two pairs of pistons are moving out of phase with each other, and, because two revolutions of the crankshaft are needed for all 4 cylinders to fire.

Overall, the bottom frequency response plot shows the separate energy components versus frequency.

White Noise and Brownian Noise in a Fourier Transform

blue graph normalized frequency, spectrum, fourier white noise
This is what the Fourier transform of white noise looks like.
blue graph triangle, brownian noise fourier transform
This is what the Fourier transform of Brownian noise looks like.

White noise AKA Gaussian noise is random noise — it is common in real life physical systems. Random noise is generally not predictable. The Fourier transform of white noise also has a “random” appearance in the spectrum.

Another type of noise is Brownian noise AKA random walk noise — it is common in real life physical systems. Brownian noise might have useful predictive information buried inside of it. Such predictability depends very much on the skill and experience of the person doing the analysis.

Fourier analysis is relevant and applicable to stock price fluctuation.

blue graph down slope, vibration energy frequency aircraft flying
The Fourier spectrum of an aircraft flying in turbulence is an example of Brownian energy with 2 structural vibration spikes.
red graph slope down, price energy, frequency brownian energy dow jones average
The Fourier spectrum of the Dow Jones average is another example of Brownian energy with a day trading energy spike.

Fourier Transform and Price Prediction

Online, many academics say that the Fourier transform has no value for prediction of stock prices, etc. However, in the aerospace and defense industry, analysts work with frequency-domain tools every day. In aerospace, some in-house methods are well beyond the textbooks and white paper literature. In academia, many signal processing methods are out of date, such as the discussion of using spline techniques on low-pass digital filters.

The frequency response spectrum separates the different energy components so that analysts can see the content of the time series. The Fourier transform is used extensively in mathematics, engineering, and the physical sciences.

Volatility, Noise, and Prediction Skill

We can stack Fourier transforms to visualize changes in the spectrum over time.  This technique is used to analyze dynamic systems. It is known as a waterfall plot.  In the following sequence of images, we show the time-changing spectrum behavior for IBM stock prices. Notice that the spectral appearance does not resemble the spectrum for random noise behavior (shown earlier). Over time, the stock price energy is moving, heaving, and shifting. Something quantitative is happening.

blue graphs mountains, waterfall plots waves
fourier transform IBM waterfall spectrum graph line, frequency magnitude not stacked
fourier transform IBM waterfall spectrum graph line, frequency magnitude 1 day stacked
fourier transform IBM waterfall spectrum graph line, frequency magnitude 10 days stacked
fourier transform IBM waterfall spectrum graph line, frequency magnitude 50 days stacked
fourier transform IBM waterfall spectrum graph line, frequency magnitude 150 days stacked
fourier transform IBM waterfall spectrum graph line, frequency magnitude 252 days stacked

We may also choose to focus on time-changing behaviors for one selected frequency, as shown by the red line in the figure. The following images show four selected frequencies for IBM. In each case, we observe “quasi-periodic” waves, an indication of organized behavior, not random behavior.

blue graphs mountains, red line, one frequency over time, waterfall plots squares
IBM spectral line quasi-periodic gray, cos sin
IBM spectral line quasi-periodic gray, cos sin up down one quarter
IBM spectral line quasi-periodic gray, up down pattern one month
IBM spectral line quasi-periodic gray, pattern two weeks

Conclusion

The Fourier transform robustly helps to clear up unwanted noise, and to extract what we want to see — patterns and non-random behavior.

Once we have identified something quantitative, we can predict something accurately. Typically, the next step is to apply DSP (Digital Signal Processing) which is related to Fourier methods.

Summary:

  • The Fourier Transform uses sines and cosines to fit the data perfectly.
  • The spectrum shows the energy of the data as a function of frequency.
  • For best results, take a data sample long enough to be representative. 
  • Gaussian (random) white noise usually cannot be predicted directly.
  • Brownian noise typically has a slope of minus 1.  Information might be buried in it.
  • A waterfall plot shows the dynamic changes of the system over time.
  • DSP helps extract the information from the data that we want to see.
  • Statistical methods cannot do that.
blue line fourier transform for stock price prediction remove noise 30 days average daily close

Additional Resources: Fourier Analysis in Modeling and Prediction

Fourier Videos

At the University of Washington Brunton Lab, nonlinear modeling projects are funded by government organizations including DARPA, NSF, and DOE.  Thirty nine videos are available on Fourier analysis. Select the desired video from the upper right-hand corner.  The Brunton playlist has 17 different topics in nonlinear modeling. Lastly, here is the full online book “Data-Driven Science and Engineering” by Steve Brunton, et al.

The Fourier Matrix: A High-Tech Math Invention

The below illustration visually shows a Fourier transform matrix. Indeed, it is the matrix that performs the actual transformation. The matrix contains weighting factors, ranging from -1 to +1.
  • Red is the minimum value (minus 1)
  • White is no weight (value of 0)
  • And blue is the maximum value (plus 1)
insight inc data prediction, fourier matrix, colorful, red blue graph
The colors reveal that the weighting factors have undulations and symmetries. Remarkably these weighting factors transform 2-D time series data values into 3-D energy packets!
The founder of Insight Inc became acquainted with these so called “frequency domain methods” during his experience on US nuclear submarines under secret clearance.

Chaos or Symmetry?

Only one thing in the ocean environment is random. And that is the white noise background of the ocean itself. However, everything else has a frequency-specific signature and energy. A kind of ever prevailing beauty and symmetry.
Certainly, entities with such geometry can be detected, tracked, and identified using SONAR or signal processing techniques. For example, the founder of Insight Inc used spectral analysis and advanced modeling methods to study detailed data sets. He did this within the realm of aerospace engineering under secret clearance.
To sum up, signal processing identifies patterns by making a clean organized signal.

Leave a Reply

Your email address will not be published. Required fields are marked *