Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using fourier analysis for time series prediction

For data that is known to have seasonal, or daily patterns I'd like to use fourier analysis be used to make predictions. After running fft on time series data, I obtain coefficients. How can I use these coefficients for prediction?

I believe FFT assumes all data it receives constitute one period, then, if I simply regenerate data using ifft, I am also regenerating the continuation of my function, so can I use these values for future values?

Simply put: I run fft for t=0,1,2,..10 then using ifft on coef, can I use regenerated time series for t=11,12,..20 ?

like image 584
BBSysDyn Avatar asked Dec 18 '10 18:12

BBSysDyn


People also ask

What is the effect of Fourier analysis on time series data?

Fourier analysis converts a time series from its original domain to a representation in the frequency domain and vice versa. In simpler words, Fourier Transform measures every possible cycle in time-series and returns the overall “cycle recipe” (the amplitude, offset and rotation speed for every cycle that was found).

What is Fourier transformation in time series?

The Fourier Transform is a great tool for extracting the different seasonality patterns from a single time series variable. The Fourier Transform allows you to do exactly this: describing a time series as a frequency rather than as a function of time.

What is the purpose of performing a discrete Fourier transform DFT on time series data?

In mathematics, the discrete Fourier transform (DFT) converts a finite sequence of equally-spaced samples of a function into a same-length sequence of equally-spaced samples of the discrete-time Fourier transform (DTFT), which is a complex-valued function of frequency.

What can Fourier analysis be used for?

Fourier analysis is used in electronics, acoustics, and communications. Many waveforms consist of energy at a fundamental frequency and also at harmonic frequencies (multiples of the fundamental). The relative proportions of energy in the fundamental and the harmonics determines the shape of the wave.


2 Answers

I'm aware that this question may be not actual for you anymore, but for others that are looking for answers I wrote a very simple example of fourier extrapolation in Python https://gist.github.com/tartakynov/83f3cd8f44208a1856ce

Before you run the script make sure that you have all dependencies installed (numpy, matplotlib). Feel free to experiment with it. enter image description here P.S. Locally Stationary Wavelet may be better than fourier extrapolation. LSW is commonly used in predicting time series. The main disadvantage of fourier extrapolation is that it just repeats your series with period N, where N - length of your time series.

like image 134
tartakynov Avatar answered Sep 25 '22 13:09

tartakynov


It sounds like you want a combination of extrapolation and denoising.

You say you want to repeat the observed data over multiple periods. Well, then just repeat the observed data. No need for Fourier analysis.

But you also want to find "patterns". I assume that means finding the dominant frequency components in the observed data. Then yes, take the Fourier transform, preserve the largest coefficients, and eliminate the rest.

X = scipy.fft(x) Y = scipy.zeros(len(X)) Y[important frequencies] = X[important frequencies] 

As for periodic repetition: Let z = [x, x], i.e., two periods of the signal x. Then Z[2k] = X[k] for all k in {0, 1, ..., N-1}, and zeros otherwise.

Z = scipy.zeros(2*len(X)) Z[::2] = X 
like image 40
Steve Tjoa Avatar answered Sep 24 '22 13:09

Steve Tjoa