fast fourier transform. fourier 变换 : 存在的条件 : 反变换 : jean baptiste joseph fourier...

44
Fast Fourier Transform

Upload: maximus-pelfrey

Post on 14-Dec-2015

309 views

Category:

Documents


13 download

TRANSCRIPT

Page 1: Fast Fourier Transform. Fourier 变换 : 存在的条件 : 反变换 : Jean Baptiste Joseph Fourier (1768 - 1830)

Fast Fourier Transform

Page 2: Fast Fourier Transform. Fourier 变换 : 存在的条件 : 反变换 : Jean Baptiste Joseph Fourier (1768 - 1830)

Fourier 变换 :

G(k) g(x) g(x)e ikxdx

存在的条件 :

g(x)2 dx

反变换 :

g(x) 1 G(k) 1

2G(k)eikxdk

Jean Baptiste Joseph Fourier (1768 - 1830)

Page 3: Fast Fourier Transform. Fourier 变换 : 存在的条件 : 反变换 : Jean Baptiste Joseph Fourier (1768 - 1830)

当 g(x) 为实函数

Gr (k) g(x)cos(kx)dx

Gi (k) g(x)sin(kx)dx

g(x) Gr (k) iGi (k)

g(x) G(k) A(k)ei(k )

A G Gr2 Gi

2

A amplitude spectrum, or magnitude spectrum

phase spectrum

A2 G 2 Gr2 Gi

2 power spectrum

Page 4: Fast Fourier Transform. Fourier 变换 : 存在的条件 : 反变换 : Jean Baptiste Joseph Fourier (1768 - 1830)

delta 函数

x x e ikxdx

x e ik0 1

x 1

t

(t)

-20 -10 10 20

-0.5

0.5

1

1.5

2

TopHat 函数

G(k) g(x)e ikxdx

g(x) 1; x 1

0; x 1

G(k) 2 cos(kx)dx0

1 2

sin(k)k

2sinc(k)

Page 5: Fast Fourier Transform. Fourier 变换 : 存在的条件 : 反变换 : Jean Baptiste Joseph Fourier (1768 - 1830)

0{cos( )}tFcos(0t)

t

cosine 函数

G(k) cos(k0x)e ikxdx

g(x) cos(k0x)

G(k) cos(k0x)cos(kx)dx

(k k0 )(k k0 )

G(k) sin(k0x)e ikxdx

g(x) sin(k0x)

G(k) i sin(k0x)sin(kx)dx

i (k k0 ) (k k0 )

sine 函数

Page 6: Fast Fourier Transform. Fourier 变换 : 存在的条件 : 反变换 : Jean Baptiste Joseph Fourier (1768 - 1830)

-3 -2 -1 1 2 3

-2

2

4

6

8

g x G(k)

)()()( )( axdeeaxgdxeaxgaxg ikaaxikikx

g x a e ikaG(k)

g ax g(ax)e ikxdx

1a

g(ax)e i

k

aax

d(ax)

g ax 1a

G(ka

)

位移性质 :

相似性质 :

a-a

12a

1a

Page 7: Fast Fourier Transform. Fourier 变换 : 存在的条件 : 反变换 : Jean Baptiste Joseph Fourier (1768 - 1830)

g(x)2 dx

G(k)2 d(k)

energy theorem, Rayleigh’s theorem

g(x) k0 g(x)e ikxdx

k0

g(x)dx

The zero frequency point

反变换 :

g(x) 1 G(k) 1

2G(k)eikxdk

,)()(

dxexgkG ikx

) (

) (2

) ( )( 2

1)(

2

1

xg

xx

xxikikx dkexgdxdkekG

代入

Page 8: Fast Fourier Transform. Fourier 变换 : 存在的条件 : 反变换 : Jean Baptiste Joseph Fourier (1768 - 1830)

常用的常用的 FourierFourier 变换变换

Page 9: Fast Fourier Transform. Fourier 变换 : 存在的条件 : 反变换 : Jean Baptiste Joseph Fourier (1768 - 1830)

连续傅立叶变换(Continuous Fourier Transform)

dfefHth

dtethfH

ift

ift

2

2

离散傅立叶变换(Discrete Fourier Transform)

1

0

2

1

0

2

1 N

n

Niknnk

N

k

Niknkn

eHN

h

ehH

dxuxixfuFxf ]2exp[)()()( where 1i

)()}({1 xfuF

duuxiuF ]2exp[)(

1

0

]/2exp[)(1

)(N

x

NuxixfN

uF For u=0,1,2,…,N-1

1

0

]/2exp[)()(N

u

Nuxiufxf For x=0,1,2,…,N-1

连续傅立叶变换 (Continuous Fourier Transform)

离散傅立叶变换 (Discrete Fourier Transform)

常用的其他定义

Page 10: Fast Fourier Transform. Fourier 变换 : 存在的条件 : 反变换 : Jean Baptiste Joseph Fourier (1768 - 1830)

连续 Fourier 变换 (Continuous Fourier Transform)

反变换

DFT:

IDFT:

Page 11: Fast Fourier Transform. Fourier 变换 : 存在的条件 : 反变换 : Jean Baptiste Joseph Fourier (1768 - 1830)

矩阵形式的 DFT

HFn

F11 Fxf fF

nx H1

k

n

k

jknj xf

1

0

j

n

j

jknk f

nx

1

0

1

n

i

n e

2

n

i

n e

2

Page 12: Fast Fourier Transform. Fourier 变换 : 存在的条件 : 反变换 : Jean Baptiste Joseph Fourier (1768 - 1830)

omega = exp(-2*pi*i/n);j = 0:n-1;k = j';F = omega.^(k*j);

% an easier,and quicker, way to generate F isF = fft(eye(n));

Page 13: Fast Fourier Transform. Fourier 变换 : 存在的条件 : 反变换 : Jean Baptiste Joseph Fourier (1768 - 1830)

Fast Fourier TransformFast Fourier Transform

• The Fast Fourier Transform (FFT) is a very efficient algorithm for performing a discrete Fourier transform

• FFT principle first used by Gauss in 1805?• FFT algorithm published by Cooley & Tukey i

n 1965• In 1969, the 2048 point analysis of a seismic t

race took 13 ½ hours. Using the FFT, the same task on the same machine took 2.4 seconds!

Page 14: Fast Fourier Transform. Fourier 变换 : 存在的条件 : 反变换 : Jean Baptiste Joseph Fourier (1768 - 1830)

Requires N2 complex multiplies and N(N-1) complex additions

1

0

2

][][N

n

N

nkj

enxkX

1

0

2

][1

][N

n

N

nkj

ekXN

nx

离散 Fourier 变换 (DFT)

( 此处定义与教材和 MATLAB 保持一致 )

*][ )( knN

knN

nNkN WWW

nNkN

NnkN

knN WWW ][][

对称性 :

周期性 :

WN=e-j2π/N

Page 15: Fast Fourier Transform. Fourier 变换 : 存在的条件 : 反变换 : Jean Baptiste Joseph Fourier (1768 - 1830)

1

02/

1

02/

1

0

21

0

2

1

0

22

22

]12[]2[

)](12[)](2[

][][

][][

NN

NN

r

rkN

kN

r

rkN

r

rkN

kN

r

rkN

oddn

nkN

evenn

nkN

N

n

nkN

WrxWWrx

WrxWWrx

WnxWnx

WnxkX

samples odd ofDFT N/2

sampleseven ofDFT N/2

][][][ kHWkGkX kN

两个长度为 N/2 的 DFT 之和

Page 16: Fast Fourier Transform. Fourier 变换 : 存在的条件 : 反变换 : Jean Baptiste Joseph Fourier (1768 - 1830)

• Cross feed of G[k] and H[k] in flow diagram is called a “butterfly”, due to the shape

rNW

)(

)2(

rN

NrN

W

W

rNW -1

or simplify:

X[0…7]

x[0,2,4,6]

x[1,3,5,7]

N/2

DFT

N/2

DFT

7...0NW

Page 17: Fast Fourier Transform. Fourier 变换 : 存在的条件 : 反变换 : Jean Baptiste Joseph Fourier (1768 - 1830)

1

0

/2N

k

Niknkn exX

1

0

/21 N

n

Niknnk eX

Nx

1

0

21

0

2 1 N

nn

N

kk X

Nx

)( , /2101/20

12/

012

)2//(2/212/

02

)2//(2

12/

012

/)12(212/

02

/)2(2

1

0

/2

Nik

kkk

Nikk

N

kk

NijkNikN

jj

Nijk

N

jj

NkjiN

jj

Nkji

N

jj

Nijkk

eWXWXXeX

xeexe

xexe

xeX

1,,1,0 Nk

Page 18: Fast Fourier Transform. Fourier 变换 : 存在的条件 : 反变换 : Jean Baptiste Joseph Fourier (1768 - 1830)

因为 WN/2 = -1, X k0 和 X k

1 具有周期 N/2,

)12/,...,1,0(

101

100

NkXWXX

XWXX

kk

kk

kk

kk

)]]([)()[()]([)()(

)]()[()()(

)()(

74

32

54

164

22

44

0

74

32

54

164

22

44

0

76

54

32

166

44

22

0

77

66

55

44

33

22

10

7

0

xWxWxWxWxWxWxWx

xWxWxWxWxWxWxWx

xWxWxWxWxWxWxWx

xWxWxWxWxWxWxWxxWX

kkkkkkk

kkkkkkk

kkkkkkk

kkkkkkk

jj

jkk

12/,...,1,0for , 102

10 NkXWXXXWXX kk

kN/kkk

kk

对 N=8 ,

There are N/2 butterflies for this stage of the FFT, and each butterfly requires one multiplication

Diagrammatically (butterfly),

Page 19: Fast Fourier Transform. Fourier 变换 : 存在的条件 : 反变换 : Jean Baptiste Joseph Fourier (1768 - 1830)

The splitting of {Xk} into two half-size DFTs can be repeated on X k

0 and X k1 themselves,

713

303

13

612

202

12

511

101

11

410

000

10

313

303

03

212

202

02

111

101

01

010

000

00

XXWXX

XXWXX

XXWXX

XXWXX

XXWXX

XXWXX

XXWXX

XXWXX

14/,...,1,0for ,

,112101

4112101

0120004

012000

NkXWXXXXXX

XWXXXWXX

kk

kN/kkk

kk

kk

kN/kkk

kk

Page 20: Fast Fourier Transform. Fourier 变换 : 存在的条件 : 反变换 : Jean Baptiste Joseph Fourier (1768 - 1830)

– { X k00} is the N/4-point DFT of {x0, x4,…, xN-4},

– { X k01} is the N/4-point DFT of {x2, x6,…, xN-2},

– { X k10} is the N/4-point DFT of {x1, x5,…, xN-3},

– { X k11} is the N/4-point DFT of {x3, x7,…, xN-1} .

713

303

13

111

2101

111

612

202

12

110

0100

110

511

101

11

111

2101

101

410

000

10

110

0100

100

313

303

03

011

2001

011

212

202

02

010

0000

010

111

101

01

011

2001

001

010

000

00

010

0000

000

XXWXXXWXX

XXWXXXWXX

XXWXXXWXX

XXWXXXWXX

XXWXXXWXX

XXWXXXWXX

XXWXXXWXX

XXWXXXWXX

Page 21: Fast Fourier Transform. Fourier 变换 : 存在的条件 : 反变换 : Jean Baptiste Joseph Fourier (1768 - 1830)

• bit reversal0, 1, 2, 3, 4, 5, 6, 7 is reordered to 0, 4, 2, 6, 1, 5, 3, 7

Decimal Binary Binary Decimal

0 000 000 0

1 001 100 42 010 010 23 011 110 64 100 001 15 101 101 56 110 011 37 111 111 7

Page 22: Fast Fourier Transform. Fourier 变换 : 存在的条件 : 反变换 : Jean Baptiste Joseph Fourier (1768 - 1830)

828

38

48

58

68

78

28

48

68

28

48

68

38

688

48

78

28

58

48

48

48

48

58

28

78

488

68

38

68

48

28

68

48

28

78

68

58

48

38

288

8

1

11

1

1111

1

11

1

11111111

F

)/2exp( nin

定义 c=[0 2 4 6 1 3 5 7]

Page 23: Fast Fourier Transform. Fourier 变换 : 存在的条件 : 反变换 : Jean Baptiste Joseph Fourier (1768 - 1830)

58

788

38

28

48

68

68

28

68

28

48

48

78

58

388

68

48

28

58

788

38

28

48

68

68

28

68

28

48

48

78

58

388

68

48

28

8

1

11

1

11111111

1

11

1

11111111

)(:,

cF

444

4448 )(:,

FF

FFcF

428

38

28

84

000

000

000

0001

8

Page 24: Fast Fourier Transform. Fourier 变换 : 存在的条件 : 反变换 : Jean Baptiste Joseph Fourier (1768 - 1830)

)7:2:1(

)7:2:0(

)7:2:1(

)7:2:0()()(:,

4

4

4

4

444

44488

xF

xF

I

I

x

x

FF

FFcxcFxF

BT

BT

T

B

T

ydyy

ydyy

d

xFy

xFy

xFy

*.)7:4(

*.)3:0(

,,,1

)7:2:1(

)7:2:0(

38

288

8

4

4

Page 25: Fast Fourier Transform. Fourier 变换 : 存在的条件 : 反变换 : Jean Baptiste Joseph Fourier (1768 - 1830)

function y=fft(x,n)

if n=1

y=x

else

m=n/2; w=e-i2πn

yT=fft(x(0:2:n),m)

yB=fft(x(1:2:n),m)

d=[1,w,…,wm-1]T

z=d.*yB

y=[yT+z; yB+z]

end

设 n=2t

12/2/

2/2/

2/2/

1

,,,1diag,

/,2,

LLLL

LL

LLL

qLrq

ntn

I

IB

LnrLBIA

PAAF

Page 26: Fast Fourier Transform. Fourier 变换 : 存在的条件 : 反变换 : Jean Baptiste Joseph Fourier (1768 - 1830)

fftgui(y) 产生 4 个 plots: real(y),imag(y),real(fft(y)),imag(fft(y))

1,...,0,1

0

njyY k

n

k

jknj

n

i

n e

2

print -deps FftGui.epsprint –depsc2 FftGui.eps

Page 27: Fast Fourier Transform. Fourier 变换 : 存在的条件 : 反变换 : Jean Baptiste Joseph Fourier (1768 - 1830)

y0=1,y1=…=yn-1=0,

1,...,0,1001 0 njeY j

Page 28: Fast Fourier Transform. Fourier 变换 : 存在的条件 : 反变换 : Jean Baptiste Joseph Fourier (1768 - 1830)

y0=0,y1=1,y2=…=yn-1=0,

00102

n

ji

j eY

Page 29: Fast Fourier Transform. Fourier 变换 : 存在的条件 : 反变换 : Jean Baptiste Joseph Fourier (1768 - 1830)

FFT is the sum of two sinusoids

Page 30: Fast Fourier Transform. Fourier 变换 : 存在的条件 : 反变换 : Jean Baptiste Joseph Fourier (1768 - 1830)

Nyquist point

Page 31: Fast Fourier Transform. Fourier 变换 : 存在的条件 : 反变换 : Jean Baptiste Joseph Fourier (1768 - 1830)

若 y 是长度为 n 的实向量 ,Y=fft(y), 则

real(Y0)=∑yj

imag(Y0)=0

real(Yj)=real(Yn-j), j=1,…,n/2

imag(Yj)=-imag(Yn-j),j=1,…,n/2

Page 32: Fast Fourier Transform. Fourier 变换 : 存在的条件 : 反变换 : Jean Baptiste Joseph Fourier (1768 - 1830)

697

770

852

941

1209 1336 1477

% the sampling rate. Fs = 32768; t = 0:1/Fs:0.25;

% the button in position (k,j)for k=1:4 for j=1:3 y1 = sin(2*pi*fr(k)*t); y2 = sin(2*pi*fc(j)*t); y = (y1 + y2)/2; input('Press any key:)'); sound(y,Fs) endend

Page 33: Fast Fourier Transform. Fourier 变换 : 存在的条件 : 反变换 : Jean Baptiste Joseph Fourier (1768 - 1830)
Page 34: Fast Fourier Transform. Fourier 变换 : 存在的条件 : 反变换 : Jean Baptiste Joseph Fourier (1768 - 1830)
Page 35: Fast Fourier Transform. Fourier 变换 : 存在的条件 : 反变换 : Jean Baptiste Joseph Fourier (1768 - 1830)

load sunspot.dat

t = sunspot(:,1)'; wolfer = sunspot(:,2)'; n = length(wolfer); c = polyfit(t,wolfer,1); trend = polyval(c,t); plot(t,[wolfer; trend],'-', t,wolfer,'k.')

Page 36: Fast Fourier Transform. Fourier 变换 : 存在的条件 : 反变换 : Jean Baptiste Joseph Fourier (1768 - 1830)
Page 37: Fast Fourier Transform. Fourier 变换 : 存在的条件 : 反变换 : Jean Baptiste Joseph Fourier (1768 - 1830)

y = wolfer - trend; Y = fft(y);

Fs = 1; % Sample rate f = (0:n/2)*Fs/n; pow = abs(Y(1:n/2+1)); plot([f; f],[0*pow; pow],'c-', … f,pow,'b.', ... 'linewidth',2, 'markersize',16)

Page 38: Fast Fourier Transform. Fourier 变换 : 存在的条件 : 反变换 : Jean Baptiste Joseph Fourier (1768 - 1830)
Page 39: Fast Fourier Transform. Fourier 变换 : 存在的条件 : 反变换 : Jean Baptiste Joseph Fourier (1768 - 1830)
Page 40: Fast Fourier Transform. Fourier 变换 : 存在的条件 : 反变换 : Jean Baptiste Joseph Fourier (1768 - 1830)

plot(fft(eye(17)))axis square

Page 41: Fast Fourier Transform. Fourier 变换 : 存在的条件 : 反变换 : Jean Baptiste Joseph Fourier (1768 - 1830)

Chebyshev Polynomial

)arccoscos()( xnxCn iiininn eexeexC

2

1,

2

1)(

wwzwwzC nn

n

1

2

1,

2

1)(

eezneezC nnn 2

1),cosh(

2

1)(

扩充到复平面

扩充到 |z|>1

kkkk 12

1 2

递推关系 : )()(2)( 11 xCxxCxC nnn

0)1( 2'"2 ynxyyx满足微分方程 :

第二类 Chebyshev 多项式

)sinh(cosh

)coshsinh()(

1

1

t

tntun

Page 42: Fast Fourier Transform. Fourier 变换 : 存在的条件 : 反变换 : Jean Baptiste Joseph Fourier (1768 - 1830)

shg,hold onfplot('x',[-1,1])fplot('2*x^2-1',[-1,1])fplot('4*x^3-3*x',[-1,1])fplot('8*x^4-8*x^2+1',[-1,1])fplot('16*x^5-20*x^3+5*x',[-1,1])

Page 43: Fast Fourier Transform. Fourier 变换 : 存在的条件 : 反变换 : Jean Baptiste Joseph Fourier (1768 - 1830)

“We do not make things,

We make things better.”

Page 44: Fast Fourier Transform. Fourier 变换 : 存在的条件 : 反变换 : Jean Baptiste Joseph Fourier (1768 - 1830)

The price (in euros) of a magazine has changed as follows

Estimate the price in November 2002 by extrapolating these data.

Nov. 87

Dec. 88

Nov. 90

Jan. 93

Jan. 95

Jan. 96

Nov. 96

Nov. 00

4.5 5 6 6.5 7 7.5 8 8

1 14 37 63 87 99109

157

180

4.5 5 6 6.5 7 7.5 8 8 ?