time series analysis and fourier use a tool like matlab ... (fast) fourier transform [fft] –...

19
Time Series Data and Fourier Transforms Jason Bailey

Upload: vuongcong

Post on 25-Mar-2018

229 views

Category:

Documents


3 download

TRANSCRIPT

Time Series Data and Fourier Transforms

Jason Bailey

Quick Summary

• Look Time Series Data

• See data in Time domain (time series) and Frequency domain (using Fourier Transform)

• Application: Filter data/Extract pattern with Fourier Transform

• FFT - Fast Fourier Transform

07-Apr 14-Apr 21-Apr-600

-400

-200

0

200

400

600

800

1000

Date

Num

ber

of

Vis

its

Visitors to a Learning Site

What is Time Series Data

• A sequence of data points

• Typically at successive points in time spaced at uniform time intervals

• Used:

• statistics, signal processing, pattern recognition, finance, weather forecasting, earthquake prediction, control engineering and communications engineering

http://en.wikipedia.org/wiki/Time_series

What if we want to extract a pattern

from time series data?

12AM 12AM 12AM 12AM 12AM-600

-400

-200

0

200

400

600

800

1000

Time

Num

ber

of

Vis

itsVisitors to a Learning Site

Original Data

lunchtime rush

unidentified

https://gist.github.com/espeecat/5438953

A sine wave or sinusoid

Cosine too

y(t) = A sin(2πft +ф) Sometimes 2πf written as ω

Much better to see it in a graph

• Use a tool like Matlab

– A programmable calculator with good graph/chart abilities

• Other tools are available and much cheaper

An example of a sinusoid and FFT

0 0.5 1 1.5 2 2.5-2

-1

0

1

2

Time (seconds)

Am

plitu

de

plot of y=2*sin(2*pi*f*t) f=1Hz

0 5 10 15 200

200

400

600

800

Frequency (Hz)

Abs A

mp

https://gist.github.com/espeecat/5439069

The Fourier Transform (FFT) • Based on Fourier Series - represent periodic

time series data as a sum of sinusoidal components (sine and cosine)

• (Fast) Fourier Transform [FFT] – represent time series in the frequency domain (frequency and power)

• The Inverse (Fast) Fourier Transform [IFFT] is the reverse of the FFT

• Like graphic equaliser on music player

Combining Sinusoids

0 1 2 3 4 5 6-10

-5

0

5

10

Time (s)

0 1 2 3 4 5 6-10

-5

0

5

10

Time (s)

0 1 2 3 4 5 6-10

-5

0

5

10

Time (s)

0 1 2 3 4 5 6-10

-5

0

5

10

Time (s)

Looking at the Fourier Transforms

0 1 2 3 4 5 6 7 80

500

1000

1500

2000

Frequency (Hz)

0 1 2 3 4 5 6 7 80

500

1000

1500

2000

Frequency (Hz)

0 1 2 3 4 5 6 7 80

500

1000

1500

2000

Frequency (Hz)

0 1 2 3 4 5 6 7 80

500

1000

1500

2000

Frequency (Hz)

Applications of Fourier Transform

• Shazam – “finger printing” using Fourier Transforms

• Images – The Gabor Transform for facial recognition?

• Filtering data/ Extracting patterns

• Sound processing – discarding sound

• System Identification

The (Fast) Fourier Transform

• Discrete-time Fourier Transform –assumes sampled data and limited length

• Implementations available in lots of programming languages e.g. http://www.fftw.org/

• Python numpy.fft

Filtering Time Series Data

0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5-20

-10

0

10

20

0 50 100 150 200 250 300 350 400 450 5000

500

1000

1500

2000

2500

Frequency Hz.

0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5-15

-10

-5

0

5

10

15

Time (s)

Am

plitu

de

filtered data

original data

Original data and filtered data

0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5-15

-10

-5

0

5

10

15

Time (s)

Am

plitu

de

Comparison of original and filtered data

filtered data

original data

Thank you

Alternative to Matlab

• SciLab – https://www.scilab.org/

• Octave - http://www.gnu.org/software/octave/

• R - http://www.r-project.org/

• Programming language & graph library

Twitter @espeecat www.jasonbailey.net

0 50 100 150 200 250 3000

2

4

6

8

10

12

14x 10

4

Discrete-Time Fourier Transform

• ω = 2πƒ –angular frequency

• Euler Formula used but this represents