Date post: | 21-Dec-2015 |
Category: |
Documents |
View: | 223 times |
Download: | 4 times |
Lecture 16
Basic properties of Fourier Transforms
MatLab Code% setupN=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 transformpr=ifft(pt); % inverse transform
p(t)
t
t
ifft(fft(p))
1: Relationship to integral transforms
Integral transforms:
C() = -+
T(t) exp(-it) dt
T(t) = (1/2) -+
C() exp(it) d
Discrete transforms
Ck = n=-N/2N/2 Tn exp(-2ikn/N ) with k=-½N, …, ½N
Tn = N-1k=-N/2N/2 Ck exp(+2ikn/N ) with n=-½N, …, ½N
(this agrees with definition in MatLab HELP)
kk and tn = nt and = 2/(Nt)
so t = 2/N
Ck = C(k) = -+
T(t) exp(-ikt) dt
t n=-N/2N/2 T(tn) exp(-iktn)
= t n=-N/2N/2 Tn exp(-i k nt)
= t n=-N/2N/2 Tn exp(-2i kn )
So forward integral transform is t times discrete forward transform
kk and tn = nt and = 2/(Nt)
so t=2/N and = 1/(Nt)
T(tn) = (1/2) -+
C() exp(itn) d
(/2) k=-N/2N/2 C(k) exp(iktn)
= (1/t) N-1 k=-N/2N/2 Ck exp(i k nt)
= (1/t) N-1 k=-N/2N/2 Ck exp(2i kn )
So inverse integral transform is 1/t times inverse discrete transform
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)
Error Estimates for the DFTAssume uncorrelated, normally-distributed data, dn=Tn, with
variance d2
The matrix G in Gm=d is Gnk=N-1 exp(+2ikn/N )
The problem Gm=d is linear, so the unknowns, mk=Ck, (the coefficients of the complex exponentials) are also normally-distributed.
Since exponentials are orthogonal, GHG=N-1I is diagonaland Cm= d
2 [GHG]-1 = N-1d2I is diagonal, too
Apportioning variance equally between real and imaginary parts of Cm, each has variance 2= N-1d
2/2.The spectrum sm
2= Crm
2+ Cim
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-1d2/2
examplef(t) = exp(-a2t2)
f() = -+ exp(-a2t2) exp(-it) dt
= 2 0+ exp(-a2t2) cos(t) dt
= exp( -2/4a2 ) / 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 .
t fft( exp(-a2t2) ) with a=0.05
exp( -2/4a2 ) / a with a=0.05
C() is the area under T(t)
2: area under T(t)
0
T(t)
area
C() = -+
T(t) exp(-it) dt
C()
= -+
T(t) exp(0) dt
= -+
T(t) dt = area
area = dt sum(p) = 18.2245
t
t
area = t real(fft(p)) = 18.2245
Multiplying C() by
exp(-it0)
shifts the timeseries T(t) by t0.
3: Time shift
0t
T(t)
0 t0
T(t-t0)
C() = -+
T(t) exp(-it) dt
Transform(shifted) =
-+
T(t-t0) exp(-it) dt =
-+
T(t’) exp{-it’+t0)} dt’ =
exp(-it0) -+
T(t’) exp(-it’) dt’ =
exp(-it0) Transform(unshifted)
t’ = t-t0 so t=t’+t0
and dt’=dtand t’ as t
p(t)
ifft(exp(-it0)fft(p(t))) with t0=50
t
t
Multiplying C() by
i
Gives the transform of dT/dt
4: derivative
transform(dT/dt) =
-+
dT/dt exp(-it) dt
T exp(it |-+
+i -+
T exp(it dt
= -i transform(T)
Integration by parts
u dv = uv - v du
u= exp(it) dv=(dT/dt) dt
du = -i exp(-it) dt
v = dv = T
assuming T exp(it |-+
= 0
p(t)
dp/dt
ifft( i fft(p))
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
p(t)
tcumsum(p)
ifft(fft(p)/(i))a bit of drift, presumably
due to round off error
t
t
t
The transform of
the convolution of two timeseries
is the product of their
transforms
6: convolution
transform( f(t)*g(t) ) =
-+
-+
f(t-) g() d exp(it) dt
-+
g() -+
f(t-) exp(it) dt d
-+
g() -+
f(t’) exp{it’+)} dt’ d
-+
g() exp(i) d -+
f(t’) exp(it’) dt’
transform(g(t)) transform(f(t))
t’=t-sot=t’+dt’ = dt
t
t
t
f(t)g(t)
conv(g,f)
ifft(fft(g)fft(f))
7: FFT of a spike at t=0 is a constant
C() = -+
(t) exp(-it) dt = exp(0) = 1
t
p(t) is a spike at t0=0
imag(fft(p))
real(fft(p))
7: FFT of a spike at t=t0 is sinusoidal
C() = -+
(t-t0) exp(-it) dt = exp(-it0)
= cos(t0) - i sin(t0)
t
p(t) is a spike at t0=5
imag(fft(p))=sin(t0)
real(fft(p))=cos(t0)
5
8: FFT of a sinusoid cos(1t) is a pair of spikes at w=±1
Note rule -+
exp(-it) exp(it) dt = (1-2)
cos(t) = ½ { exp(it) + exp(-it) }
-+
cos(t) exp(-it) dt =
½ -+
exp(it) exp(-it) dt + ½ -+
exp(it) exp(-it) dt
= ½{ (-1) + (+1) }
t
p(t)=cos(1t)
imag(fft(p))=0real(fft(p))
±1
Aliasing
the tendency in a digital world for high frequencies to look like low
frequencies
MatLab Script to evaluate cosines at ever increasing frequency
L = 0; % make plots in groups of 10 starting at frequency L+1for 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
t
cos(kt)
k
k
t
cos(kt)
k
k
knyquist
same!
t
cos(kt)
k
kfrequencies seem to be getting lower!
t
cos(kt)
k
kbut now higher again!
in a digital world we have chosen t = 2/N
sin(ntk) = sin(knt) = sin(knt) = sin(2kn/N)cos(ntk) = cos(knt) = cos(knt) = cos(2kn/N)
let m=n+Nsin(mtk) = sin{k(n+N)wt} = sin{2k(n+N)}
= cos(2knsin(2k) sin(2kncos(2k)
cos(mtk) = cos{k(n+N)wt} = cos{2k(n+N)} = cos(2kncos(2k) sin(2knsin(2k)
but sin(2k)=0 and cos(2k)=1 for all integers k, so
sin(mtk)=sin(ntk) and cos(mtk)=cos(ntk)
in a digital world n+N = n
andsince time and frequency play symmetrical roles in exp(-it)
tk+N = tk
Example: cos(0t) with 0=ny/20 sampled with frequency 0=ny/32
Now connect the dots the resulting function has a lower frequency
n+N = n
let n=-m, then
-m = N-m
This is why the fourier coefficientsof ‘negative frequencies’
are placed at the ‘high frequency’ end of the transform vector
they “are” the high frequency coefficients
lets reconsider the example where we computed the Fourier Transform of
p(t) = exp(-a2t2)
this function is non-zero at negative times
0
p(t)
t
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 = tN-m
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
p(t)
t
Multiplying C() by exp(-it0) shifts the timeseries T(t) by t0.
What if we try to shift it by more than the length of the time-series?
It just wraps around …
Remember the Time shift ?
with N=256, trying to shift it 280t just shifts it 280-256=24
24