Professional Documents
Culture Documents
Setting
Reminder: Discrete Fourier Transform (DFT) is a reversible, composable transform for sampled data. Give it n data points, get back
n complex numbers encoding information about the data. What information? Each point of the DFT measures how much the data is
"similary to" a pure waveform. This note offers some explanation.
Each point of the DFT is an inner product of two, equal-length vectors of complex numbers: one vector is a sample of the kernel
function and the other vector is the data. The kernel function supplies waveforms; the inner product measures how "similar" the data
is to each waveform. If the data happens to be very like one of the waveforms, it will have a large-magnitude inner product with the
matching waveform and small-magnitude inner product with the others.
Example Data
As before, grab n temperature points in Seattle.
16
14
12
Out[3]=
10
10 20 30 40 50 60
Transform-Kernel Function
The kernel function of the DFT takes a wave number 0 £ k < n and a sample point index 0 £ p < n and gives back a complex
number:
-2 Π ä
kp
ã n
In[4]:= kerAk_, p_, n_E :=
n
This definition is one of the conventional ones for the DFT kernel. Note the minus sign in the exponent -- a good explanation for it
emerges from considering the DFT as a collection of inner products.
Fix k and vary p, meaning sample the kernel function (putting the kernel function on the same footing as the data)
2 Waves001.nb
Fix k and vary p, meaning sample the kernel function (putting the kernel function on the same footing as the data)
æ à æà æ à æà æ à æà
0.05
æ à æ à æ à æ à æ à æ à
Out[8]= à æ à æ à æ à æ à æ à æ
10 20 30 40 50 60
à æ à æ à æ à æ à æ à æ
-0.05
à æà æ à æà æ à æà æ
-0.10 à àæ æ à àæ æ à àæ æ
ààà æææ ààà æææ ààà æææ
Waves001.nb 3
àæ à æ àæ à æ àæ à æ
0.05
à æ à æ à æ à æ à æ à æ
Out[9]= à æ à æ à æ à æ à æ à æ
10 20 30 40 50 60
æ à æ à æ à æ à æ à æ à
-0.05
æ àæ à æ àæ à æ àæ à
-0.10 æ æà à æ æà à æ æà à
æææ ààà æææ ààà æææ ààà
lp = ListPlot@List points,
PlotMarkers ® Table@i, 8i, 0, n - 1<D,
H* NOTE:
Mathematica Bug: cannot use "Range" under PlotMarkers *L
Axes ® False, Frame ® True, AspectRatio ® 1D;
If@showLines, Show@lp, ListLinePlot@pointsDD, lpDD
For wave number k = 1, the values of the kernel sample distribute clockwise around the unit circle as closely and finely as possible.
4 Waves001.nb
44 45 46 47
42 43 48
41 49
40 50
39 51
0.10 38 52
37 53
36 54
35 55
0.05 34 56
33 57
32 58
31 59
0.00 30 0
Out[12]=
29 1
28 2
27 3
-0.05 26 4
25 5
24 6
23 7
-0.10 22 8
21 9
20 10
19 11
18 17 12
16 15 14 13
-0.10 -0.05 0.00 0.05 0.10
As points progress around the unit circle clockwise with wave-number 1, the real part (horizontal coordinate) progresses from its
maximum positive value down to its minimum negative value while the imaginary part (vertical coordinate) is negative. Then the real
part increases again while the imaginary part is positive. With wave number 59 out of 60, adjacent points skip 58 points, clockwise,
which is the same as going counterclockwise by 1 point, meaning that as the real part decreases from its maximum positive down to
its minimum negative, the imaginary part is positive, and as the real part goes back up, the imaginary part is negative.
The general rule is that the real parts for wave number k are the same as the real parts for wave number n - k, and the imaginary
parts are inverted.
When k is just one either side of n 2, we can observe this transition with maximum detail. With n = 60, k = 29, the real part starts
positive and the imaginary part starts trending negative:
Notice the one full wave shape of "outer-envelope," then file away the observation. It's for another discussion.
With n = 60, k = 30, exactly half, the imginary part goes to zero, as expected: check the point 30 on the polar plot resting exactly on
the negative real axis:
Waves001.nb 5
0.10
0.05
Out[14]= àààààààààààààààààààààààààààààààààààààààààààààààààààààààààààà
10 20 30 40 50 60
-0.05
-0.10
ææææææææææææææææææææææææææææææ
With n = 60, k = 31, the real part begins positive and the imaginary part starts trending positive:
A Closer Look
With a smaller number of sample points, the effect is easier to see.
Even k
First, inspect the case of n = 6 and the three wave numbers k = 2, 3, 4. Expect the real parts of k = 2 and k = 4 to be the same,
imaginary parts inverted; and expect the imaginary part of k = 3 to vanish, just as with k = 29, 30, 31; n = 60:
6 Waves001.nb
0.4 æ æ
à à
0.3
0.2
0.1
Out[16]=
à à
1 2 3 4 5 6
-0.1
-0.2 æ æ æ æ
-0.3
à à
0.4 æ æ æ
0.2
Out[17]= à à à à à à
1 2 3 4 5 6
-0.2
-0.4 æ æ æ
0.4 æ æ
à à
0.3
0.2
0.1
Out[18]=
à à
1 2 3 4 5 6
-0.1
-0.2 æ æ æ æ
-0.3
à à
Odd k
k = 2, 3; n = 5 exhibits the imaginary part's changing sign either side of the negative real axis, no point exactly on the negative real
axis, no case of non-zero k with vanishing imaginary part:
Waves001.nb 7
à
0.2
æ æ
Out[19]= à
1 2 3 4 5
-0.2
à
æ æ
-0.4
à
à
0.2
æ æ
Out[20]= à
1 2 3 4 5
-0.2
à
æ æ
-0.4
à
14
19
94
0.2
13
18
83
0.1
0.0 10
15
0
5
Out[21]=
-0.1
12
17
72
-0.2
11
16
61
-0.1 0.0 0.1 0.2
As expected, the polar plot for 16 = 20 - 4 looks the same, with just the points going around the unit-circle in the opposite direction
(counterclockwise):
11
16
61
0.2
12
17
72
0.1
0.0 10
15
0
5
Out[22]=
-0.1
13
18
83
-0.2
14
19
94
-0.1 0.0 0.1 0.2
In the linear plots below, see that existence of common factors in k and n mean that points are sampled at similar positions on each
wave:
Waves001.nb 9
à à à à
0.1
æ æ æ æ æ æ æ æ
Out[23]= à à à à
5 10 15 20
-0.1
à à à à
æ æ æ æ æ æ æ æ
-0.2
à à à à
When k and n don't have common factors, points are sampled at different positions on each wave:
æ à à æ
0.1
æ æ à à
Out[24]= à æ à æ
5 10 15 20
æ à à æ
-0.1
æ æ à à
à æ à æ
-0.2
à æ à æ à æ
In[25]:= Remove@a, b, x, y, u, vD
In[26]:= a=x+äy
b=u+äv
Out[26]= x+äy
Out[27]= u +äv
10 Waves001.nb
Out[28]= u x - ä u y + ä v x + v y
The one special product a b encodes both the classic dot and cross products of 2-dimensional vector geometry.
Where ai and bi are the i-th complex components of the n-vectors a and b. Mathematica has an easy way to calculate just that using
a dot -- Mathematica extends dot product to complex vectors!
Examples
Get a random n-vector of reasonably sized complex numbers
0.40878 + 0.694519 ä
0.646311 - 0.643512 ä
0.883663 + 0.0648531 ä
-0.429352 - 0.497205 ä
-0.0404347 - 0.211491 ä
x inner x should have vanishing imaginary part if we're to interpret inner as measuring similarity in high-dimensional complex space:
In[33]:= x ~cInner~ x
Out[33]= 2.74427 + 0. ä
Out[34]= 1
Out[35]= 0
How about all-versus-all (this time with a smaller number of samples, so we can see)
12 Waves001.nb
In[36]:= Table@
Table@
Neks@ker, j, 15D~cInner~ Neks@ker, i, 15D,
8j, 0, 14<D,
8i, 0, 14<D Chop
1. 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 1. 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 1. 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 1. 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 1. 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 1. 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 1. 0 0 0 0 0 0 0 0
Out[36]= 0 0 0 0 0 0 0 1. 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 1. 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 1. 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 1. 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 1. 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 1. 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 1. 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 1.
Our discretely sampled waveforms are orthonormal: maximally self-similar and having no cross-similarity, one to another. This
means they are suitable as basis vectors in n-dimensional complex vector space, at least with respect to our inner product.
Since that minus sign is built-in, we'll just use Mathematica's dot going forward, instead of using our special cInner function.
1.0 æ æ
æ æ æ æ æ æ
æ æ ææ æ æ ææ æ
Out[39]= 0.5 æ æ ææ ææ æ
æ æ æ æ
æ æ ææ æ æ æ æ ææ æ æ
æ æ æ æ
æ
æ æ
10 20 30 40 50 60
æ æ æ æ
-0.5
ææ æ
Would be surprising that it's not symmetric about wave number k = 30 = n 2. Look deeper into the peaks at low wave numbers 0
through 6 (plot indices 1 through 7)
This is telling us that, except for the wild peak at k = 0, the data looks a lot like the waveform with wave number 3. Check it out
visually:
Joined ® TrueD<D
16
14
12
Out[41]=
10
10 20 30 40 50 60
Manipulate@linearPlotComplexes@eks@ker, k, nDD,
88n, 5, "Number of Samples"<, 1, 60, 1<,
In[42]:=
Number of Samples
Wave Number
æ æ æ æ æ
0.4
Out[42]= 0.3
0.2
0.1
à à à à à
1 2 3 4 5