fast fourier transform

42
Fast Fourier Transform 向向向向向向向 向向向

Upload: xenos

Post on 19-Jan-2016

188 views

Category:

Documents


3 download

DESCRIPTION

Fast Fourier Transform. 向 华 武汉大学数学与统计学院. Fast Fourier Transform. The Fast Fourier Transform (FFT) is a very efficient algorithm for performing a discrete Fourier transform - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Fast Fourier Transform

Fast Fourier Transform

向 华

武汉大学数学与统计学院

Page 2: Fast Fourier Transform

Fast Fourier TransformFast Fourier Transform

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

• A.C.Clairaut,cosine-only finite Fourier series(1754),J.L.Lagrange,sine-only series(1762),Bernoulli,a series of sine and cosine.FFT principle first used by Gauss in 1805?

• FFT algorithm published by Cooley & Tukey in 1965• In 1969, the 2048 point analysis of a seismic trace too

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

Page 3: Fast Fourier Transform

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)

注意不同文献中的定义,特别是系数 ,exp(-i2πkx)… N

1,

2

1,

2

1

Page 4: Fast Fourier Transform

当 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 5: Fast Fourier Transform

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 6: Fast Fourier Transform

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 7: Fast Fourier Transform

-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 8: Fast Fourier Transform

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 9: Fast Fourier Transform

常用的常用的 FourierFourier 变换变换

Page 10: Fast Fourier Transform

连续傅立叶变换(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 11: Fast Fourier Transform

连续 Fourier 变换 (Continuous Fourier Transform)

反变换

DFT:

IDFT:

Page 12: Fast Fourier Transform

矩阵形式的 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 13: Fast Fourier Transform

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

% an easier,and quicker, way to generate F is

F = fft(eye(n));

Page 14: Fast Fourier Transform

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

1

0

1

0

2

][

][][

N

n

nkN

N

n

N

nki

nx

enxkX

1

0

1

0

2

][1

][1

][

N

k

nkN

N

k

N

nki

kXN

ekXN

nx

离散 Fourier 变换 (DFT)

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

*][ )( knN

knN

nNkN WWW

nNkN

NnkN

knN WWW ][][

对称性 :

周期性 :

WN=e-i 2π/N

Page 15: Fast Fourier Transform

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

• 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

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

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

)]()[()()(

)()(

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

对 N=8 ,

Decimal Binary Binary Decimal

0 000 000 01 001 100 42 010 010 23 011 110 64 100 001 15 101 101 56 110 011 37 111 111 7

bit reversal (0, 1, 2, 3, 4, 5, 6, 7 is reordered to 0, 4, 2, 6, 1, 5, 3, 7)

Page 19: Fast Fourier Transform

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

1 具有周期 N/2,

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

101

100

NkXWXX

XWXX

kk

kk

kk

kk

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

10 NkXWXXXWXX kk

kN/kkk

kk

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

Diagrammatically (butterfly),

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

0 and X k1 themselves,

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

,112101

4112101

0120004

012000

NkXWXXXXXX

XWXXXWXX

kk

kN/kkk

kk

kk

kN/kkk

kk

Page 20: Fast Fourier Transform

The FFT for eight data values d1,d2,…,d7 proceeds as follows.

22 : xx

36 : xx 55 : xx

00 : xx

63 : xx

77 : xx

41 : xx

14 : xx

0100 : Wxxx

0101 : Wxxx

0322 : Wxxx

0323 : Wxxx

0544 : Wxxx

0545 : Wxxx

0766 : Wxxx

0767 : Wxxx

0200 : Wxxx

1311 : Wxxx

0202 : Wxxx

1313 : Wxxx

0644 : Wxxx

1755 : Wxxx

0646 : Wxxx

1757 : Wxxx

0400 : Wxxx

1511 : Wxxx

2622 : Wxxx

3733 : Wxxx

0404 : Wxxx

1515 : Wxxx

2626 : Wxxx

3737 : Wxxx

参考 P55, C.W.Ueberhuber,Numerical Computation 2,Springer 1995.

Page 21: Fast Fourier Transform

– { 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 22: Fast Fourier Transform

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]

这里四页内容选自 G.H.Golub,C.F.Van Loan 的《矩阵计算》。

Page 23: Fast Fourier Transform

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

)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

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

它有一种非循环的实现方式,可用 的分解来描述:nF

其中 称为反位置换 (bit reversal permutation).nP

Page 26: Fast Fourier Transform

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

以下部分内容选自 Moler 的书《 Numerical Computing with Matlab 》。

Page 27: Fast Fourier Transform

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

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

Page 28: Fast Fourier Transform

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

00102

n

ji

j eY

Page 29: Fast Fourier Transform

FFT is the sum of two sinusoids

Page 30: Fast Fourier Transform

The Nyquist point

Page 31: Fast Fourier Transform

Some symmetries in the FFT. Ignoring the first point in each plot, the real part is symmetric about the Nyquist point and the imaginary part is antisymmetric about the Nyquist point. More precisely,

若 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

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
Page 34: Fast Fourier Transform

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.')

For centuries, people have noted that the face of the sun is not constant or uniform in appearance, but that darker regions appear at random locations on a cyclical basis. In1848,Rudolf Wolfer proposed a rule that combined the number and size of these sunspots into a single index.

Page 35: Fast Fourier Transform
Page 36: Fast Fourier Transform

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)

Now subtract off the linear trend and take the FFT.

Page 37: Fast Fourier Transform
Page 38: Fast Fourier Transform
Page 39: Fast Fourier Transform

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

Page 40: Fast Fourier Transform

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 41: Fast Fourier Transform

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 42: Fast Fourier Transform

“We do not make things,

We make things better.”