Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 16 Basic properties of Fourier Transforms.

Similar presentations


Presentation on theme: "Lecture 16 Basic properties of Fourier Transforms."— Presentation transcript:

1 Lecture 16 Basic properties of Fourier Transforms

2 MatLab Code % setup N=256; dt=1.0; tmax=dt*(N-1); t=dt*[0:N-1]; fmax=1/(2.0*dt); df=fmax/(N/2); f=df*[0:N/2,-N/2+1:-1]'; dw=2*pi*df; w=dw*[0:N/2,-N/2+1:-1]'; % a sample function, p(t) w0 = 2*pi*fmax/10; p = sin(w0*t).*exp(-0.25*w0*t); pt=fft(p); % fourier transform pr=ifft(pt); % inverse transform

3 p(t) t t ifft(fft(p))

4 1: Relationship to integral transforms Integral transforms: C(  ) =  -  +  T(t) exp(-i  t) dt T(t) = (1/2  )  -  +  C(  ) exp(i  t) d  Discrete transforms C k =  n=-N/2 N/2 T n exp(-2  ikn/N ) with k=-½N, …, ½N T n = N -1  k=-N/2 N/2 C k exp(+2  ikn/N ) with n=-½N, …, ½N (this agrees with definition in MatLab HELP)

5  k  k  and t n = n  t and  = 2  /(N  t) so  t = 2  /N C k = C(  k ) =  -  +  T(t) exp(-i  k t) dt   t  n=-N/2 N/2 T(t n ) exp(-i  k t n ) =  t  n=-N/2 N/2 T n exp(-i k  n  t) =  t  n=-N/2 N/2 T n exp(-2  i kn  ) So forward integral transform is  t times discrete forward transform

6  k  k  and t n = n  t and  = 2  /(N  t) so  t=2  /N and  = 1/(N  t) T(t n ) = (1/2  )  -  +  C(  ) exp(i  t n ) d   (  /2  )  k=-N/2 N/2 C(  k ) exp(i  k t n ) = (1/  t) N -1  k=-N/2 N/2 C k exp(i k  n  t) = (1/  t) N -1  k=-N/2 N/2 C k exp(2  i kn  ) So inverse integral transform is 1/  t times inverse discrete transform

7 So … Except for a normalization factor of  t, The discrete transform is just the “Riemann Sum” approximation to the integral transform, with particular choice  t=2  /N Properties of the integral transform carry over to the discrete transform (well, more-or-less)

8 Error Estimates for the DFT Assume uncorrelated, normally-distributed data, d n =T n, with variance  d 2 The matrix G in Gm=d is G nk = N -1 exp(+2  ikn/N ) The problem Gm=d is linear, so the unknowns, m k =C k, (the coefficients of the complex exponentials) are also normally-distributed. Since exponentials are orthogonal, G H G=N -1 I is diagonal and C m =  d 2 [G H G] -1 = N -1  d 2 I is diagonal, too Apportioning variance equally between real and imaginary parts of C m, each has variance  2 = N -1  d 2 /2. The spectrum s m 2 = C r m 2 + C i m 2 is the sum of two uncorrelated, normally distributed random variables and is thus   2 -distributed. The 95% value of   2 is about 5.9, so that to be significant, a peak must exceed 5.9N -1  d 2 /2

9 example f(t) = exp(-a 2 t 2 ) f(  ) =  -  +  exp(-a 2 t 2 ) exp(-i  t) dt = 2  0 +  exp(-a 2 t 2 ) cos(  t) dt =  exp( -  2 /4a 2 ) / a See integral 679 of CRC Math Tables Note, by the way, that the Fourier transform of a Gaussian is a Gaussian …Furthermore, the wider in t, the narrower in .

10  t fft( exp(-a 2 t 2 ) ) with a=0.05  exp( -  2 /4a 2 ) / a with a=0.05  

11 C(  ) is the area under T(t) 2: area under T(t) 0 T(t) area

12 C(  ) =  -  +  T(t) exp(-i  t) dt C(  ) =  -  +  T(t) exp(0) dt =  -  +  T(t) dt = area

13 area = dt  sum(p) = 18.2245 t t area =  t  real(fft(p)) = 18.2245

14 Multiplying C(  ) by exp(-i  t 0 ) shifts the timeseries T(t) by t 0. 3: Time shift 0 t T(t) 0 t0t0 T(t-t 0 )

15 C(  ) =  -  +  T(t) exp(-i  t) dt Transform(shifted) =  -  +  T(t-t 0 ) exp(-i  t) dt =  -  +  T(t’) exp{-i  t’+t 0 )} dt’ = exp(-i  t 0 )  -  +  T(t’) exp(-i  t’) dt’ = exp(-i  t 0 ) Transform(unshifted) t’ = t-t 0 so t=t’+t 0 and dt’=dt and t’  as t 

16 p(t) ifft(exp(-i  t 0 )  fft(p(t))) with t 0 =50 t t

17 Multiplying C(  ) by i  Gives the transform of dT/dt 4: derivative

18 transform(dT/dt) =  -  +  dT/dt exp(-i  t) dt  T exp(i  t  | -  +  +i   -  +  T exp(i  t  dt = -i  transform(T) Integration by parts  u dv = uv -  v du u= exp(i  t) dv=(dT/dt) dt du = -i  exp(-i  t) dt v =  dv = T assuming T exp(i  t  | -  +  = 0

19 p(t) dp/dt ifft( i  fft(p))

20 Dividing C(  ) by i  Gives the transform of  T dt but note that you must set the zero-frequency element manually, since 1/  is undefined at  =0. Furthermore, this process is not very stable, since 1/  can be very large for small  ’s. 5: integral

21 p(t)  t  cumsum(p) ifft(fft(p)/(i  )) a bit of drift, presumably due to round off error t t t

22 The transform of the convolution of two timeseries is the product of their transforms 6: convolution

23 transform( f(t)*g(t) ) =  -  +   -  +  f(t-  ) g(  ) d  exp(i  t) dt   -  +  g(  )  -  +  f(t-  ) exp(i  t) dt d   -  +  g(  )  -  +  f(t’) exp{i  t’+  )} dt’ d   -  +  g(  ) exp(i  ) d   -  +  f(t’) exp(i  t’) dt’  transform(g(t)) transform(f(t)) t’=t-  so t=t’+  dt’ = dt

24 t t t f(t)g(t) conv(g,f) ifft(fft(g)  fft(f))

25 7: FFT of a spike at t=0 is a constant C(  ) =  -  +   (t) exp(-i  t) dt = exp(0) = 1

26 t  p(t) is a spike at t 0 =0 imag(fft(p)) real(fft(p))

27 7: FFT of a spike at t=t 0 is sinusoidal C(  ) =  -  +   (t-t 0 ) exp(-i  t) dt = exp(-i  t 0 ) = cos(  t 0 ) - i sin(  t 0 )

28 t  p(t) is a spike at t 0 =5 imag(fft(p))=sin(  t 0 ) real(fft(p))=cos(  t 0 ) 5

29 8: FFT of a sinusoid cos(  1 t) is a pair of spikes at w=±  1 Note rule  -  +  exp(-i   t) exp(i   t) dt =  (  1 -  2 ) cos(   t) = ½ { exp(i   t) + exp(-i   t) }  -  +  cos(   t) exp(-i  t) dt = ½  -  +  exp(i   t) exp(-i  t) dt + ½  -  +  exp(i   t) exp(-i  t) dt = ½{  (  -  1 ) +  (  +  1 ) }

30 t  p(t)=cos(  1 t) imag(fft(p))=0 real(fft(p)) ±1±1

31 Aliasing the tendency in a digital world for high frequencies to look like low frequencies

32 MatLab Script to evaluate cosines at ever increasing frequency L = 0; % make plots in groups of 10 starting at frequency L+1 for k = [1:10] w1= (L+k)*dw; p=cos(w1*t); subplot(10,1,k); plot(t,p,'b'); hold on; axis( [0, tmax, -1.5, 1.5] ); end

33 t cos(k  t) k  k 

34 t cos(k  t) k  k  k  nyquist same!

35 t cos(k  t) k  k  frequencies seem to be getting lower!

36 t cos(k  t) k  k  but now higher again!

37 in a digital world we have chosen  t = 2  /N sin(  n t k ) = sin(k  n  t) = sin(kn  t) = sin(2  kn/N) cos(  n t k ) = cos(k  n  t) = cos(kn  t) = cos(2  kn/N) let m=n+N sin(  m t k ) = sin{k(n+N)  w  t} = sin{2  k(n+N)  } = cos(2  kn  sin(2  k)  sin(2  kn  cos(2  k) cos(  m t k ) = cos{k(n+N)  w  t} = cos{2  k(n+N)  } = cos(2  kn  cos(2  k)  sin(2  kn  sin(2  k) but sin(2  k)=0 and cos(2  k)=1 for all integers k, so sin(  m t k )=sin(  n t k ) and cos(  m t k )=cos(  n t k )

38 in a digital world  n+N =  n and since time and frequency play symmetrical roles in exp(-i  t) t k+N = t k

39 Example: cos(  0 t) with  0 =  ny /20 sampled with frequency  0 =  ny /32

40 Now connect the dots the resulting function has a lower frequency

41  n+N =  n let n=-m, then  -m =  N-m

42 This is why the fourier coefficients of ‘negative frequencies’ are placed at the ‘high frequency’ end of the transform vector they “are” the high frequency coefficients

43 lets reconsider the example where we computed the Fourier Transform of p(t) = exp(-a 2 t 2 ) this function is non-zero at negative times 0 p(t) t

44 you must not just leave out the values of the function at negative times you’d be leaving out half the information instead, you must wrap them to large times using the rule t -m = t N-m

45 so you must put the negative values at the right and end of the vector, p N=256; dt=0.5; tmax=dt*(N/2); tmin=dt*(-N/2+1); t=dt*[0:N/2,-N/2+1:-1]'; % note put negative times on the end... fmax=1/(2.0*dt); df=fmax/(N/2); f=df*[0:N/2,-N/2+1:-1]'; dw=2*pi*df; w=dw*[0:N/2,-N/2+1:-1]'; a=0.05; p = exp( -(a*t).^2 ); pt=fft(p); 0 p(t) t 0 t t

46 Multiplying C(  ) by exp(-i  t 0 ) shifts the timeseries T(t) by t 0. What if we try to shift it by more than the length of the time-series? It just wraps around … Remember the Time shift ?

47 with N=256, trying to shift it 280  t just shifts it 280-256=24 24


Download ppt "Lecture 16 Basic properties of Fourier Transforms."

Similar presentations


Ads by Google