Lecture 14 Notes - Power Spectral Analysis and Time Frequency Analysis
Moving Average ¶ For the moving average, let’s consider a causal moving average (remember, this is the version where we only consider values from the past in our moving average):
x t = w t + θ w t − 1 x_t = w_t + \theta w_{t-1} x t = w t + θ w t − 1 The autocovariance function for this is:
γ ( h ) = { ( 1 + θ 2 ) σ 2 h = 0 θ σ 2 ∣ h ∣ = 1 0 ∣ h ∣ > 1 \gamma(h) = \begin{cases}
(1+\theta^2)\sigma^2 & h=0\\
\theta\sigma^2 & |h|=1\\
0 & |h| > 1
\end{cases} γ ( h ) = ⎩ ⎨ ⎧ ( 1 + θ 2 ) σ 2 θ σ 2 0 h = 0 ∣ h ∣ = 1 ∣ h ∣ > 1 The spectral density is therefore:
f ( ω ) = ( 1 + θ 2 ) σ 2 + θ σ 2 ( e − 2 π i ω + e 2 π i ω ) = σ 2 ( 1 + θ 2 + 2 θ cos ( 2 π ω ) ) \begin{aligned}
f(\omega) &= (1+\theta^2)\sigma^2 + \theta\sigma^2(e^{-2\pi i \omega}+e^{2\pi i \omega}) \\
&= \sigma^2(1+\theta^2+2\theta\cos(2\pi\omega))
\end{aligned} f ( ω ) = ( 1 + θ 2 ) σ 2 + θ σ 2 ( e − 2 πiω + e 2 πiω ) = σ 2 ( 1 + θ 2 + 2 θ cos ( 2 πω )) in the second line, we used cos ( θ ) = ( e i θ + e − i θ ) / 2 \cos(\theta) = (e^{i\theta}+e^{-i\theta})/2 cos ( θ ) = ( e i θ + e − i θ ) /2 from Euler’s formula e i θ = cos ( θ ) + i sin ( θ ) e^{i\theta}=\cos(\theta)+i\sin(\theta) e i θ = cos ( θ ) + i sin ( θ ) .
What results here is that the MA process has a spectral density that decays from zero, with larger θ \theta θ corresponding to a steeper decay from ω = 0 \omega=0 ω = 0 to ω = 1 / 2 \omega=1/2 ω = 1/2 .
An overview of the DFT and periodogram ¶ An intuitive relationship between the DFT and the periodogram is that the DFT gives you a complex value that incorporates both the amplitude and phase of each frequency present in the signal, whereas the periodogram represents only the real-valued power at that frequency, removing the phase information. Let’s try this with a tiny example:
Suppose we have x 1 = 2 x_1=2 x 1 = 2 , x 2 = 3 x_2=3 x 2 = 3 , x 3 = 1 x_3=1 x 3 = 1 , and x 4 = 4 x_4=4 x 4 = 4 . We can use these to see how the periodogram is derived from squaring the DFT.
The DFT at frequency j / n j/n j / n is:
d ( j / n ) = 1 n ∑ t = 1 n x t e − i 2 π t j / n d(j/n) = \frac{1}{\sqrt{n}}\sum_{t=1}^n x_t e^{-i2\pi t j/n} d ( j / n ) = n 1 t = 1 ∑ n x t e − i 2 π t j / n The periodogram is the rescaled squared modulus:
P ( j / n ) = ( 4 / n ) ∣ d ( j / n ) ∣ 2 P(j/n) = (4/n) |d(j/n)|^2 P ( j / n ) = ( 4/ n ) ∣ d ( j / n ) ∣ 2 Since we have n = 4 n=4 n = 4 time points, the Fourier frequencies are j / n = 0 / 4 , 1 / 4 , 2 / 4 , 3 / 4 j/n = 0/4, 1/4, 2/4, 3/4 j / n = 0/4 , 1/4 , 2/4 , 3/4 . Since by symmetry P ( j / n ) = P ( 1 − j / n ) P(j/n) = P(1-j/n) P ( j / n ) = P ( 1 − j / n ) we only need j = 0 , 1 , 2 j=0,1,2 j = 0 , 1 , 2 .
We can now look at what the sine and cosine waves look like at each frequency.
Now let’s compute the DFT for each j j j :
For j = 0 j=0 j = 0 :
d ( 0 ) = 1 4 ∑ t = 1 4 x t e − i 2 π t 0 = 1 4 ∑ t = 1 4 x t = 1 2 ( 2 + 3 + 1 + 4 ) = 5 \begin{aligned}
d(0) &= \frac{1}{\sqrt{4}}\sum_{t=1}^4 x_t e^{-i2\pi t 0} \\
&= \frac{1}{\sqrt{4}}\sum_{t=1}^4 x_t\\
&= \frac{1}{2}(2+3+1+4) = 5\\
\end{aligned} d ( 0 ) = 4 1 t = 1 ∑ 4 x t e − i 2 π t 0 = 4 1 t = 1 ∑ 4 x t = 2 1 ( 2 + 3 + 1 + 4 ) = 5 For j = 1 j=1 j = 1 :
d ( 1 / 4 ) = 1 4 ∑ t = 1 4 x t e − i 2 π t 1 / 4 d(1/4) = \frac{1}{\sqrt{4}}\sum_{t=1}^4 x_t e^{-i2\pi t 1/4} d ( 1/4 ) = 4 1 t = 1 ∑ 4 x t e − i 2 π t 1/4 t e − i π t / 2 e^{-i\pi t/2} e − iπ t /2 cos ( π t / 2 ) \cos(\pi t/2) cos ( π t /2 ) sin ( π t / 2 ) \sin(\pi t/2) sin ( π t /2 ) 1 − i -i − i 0 -1 2 -1 -1 0 3 i i i 0 1 4 1 1 0
d ( 1 / 4 ) = 1 2 ( 2 ( − i ) + 3 ( − 1 ) + 1 ( i ) + 4 ( 1 ) ) = 1 2 ( 1 − i ) = 0.5 − 0.5 i d(1/4) = \frac{1}{2}(2(-i)+3(-1)+1(i)+4(1)) = \frac{1}{2}(1-i) = 0.5 - 0.5i d ( 1/4 ) = 2 1 ( 2 ( − i ) + 3 ( − 1 ) + 1 ( i ) + 4 ( 1 )) = 2 1 ( 1 − i ) = 0.5 − 0.5 i For j = 2 j=2 j = 2 :
d ( 2 / 4 ) = 1 4 ∑ t = 1 4 x t e − i 2 π t 2 / 4 = 1 2 ∑ t = 1 4 x t e − i π t = 1 2 ∑ t = 1 4 x t ( − 1 ) t = 1 2 ( 2 ( − 1 ) + 3 ( 1 ) + 1 ( − 1 ) + 4 ( 1 ) ) = 1 2 ( 4 ) = 2 \begin{aligned}
d(2/4) &= \frac{1}{\sqrt{4}}\sum_{t=1}^4 x_t e^{-i2\pi t 2/4}\\
&= \frac{1}{2}\sum_{t=1}^4 x_t e^{-i\pi t}\\
&= \frac{1}{2}\sum_{t=1}^4 x_t (-1)^t\\
&= \frac{1}{2}(2(-1)+3(1)+1(-1)+4(1))\\
&= \frac{1}{2}(4) = 2
\end{aligned} d ( 2/4 ) = 4 1 t = 1 ∑ 4 x t e − i 2 π t 2/4 = 2 1 t = 1 ∑ 4 x t e − iπ t = 2 1 t = 1 ∑ 4 x t ( − 1 ) t = 2 1 ( 2 ( − 1 ) + 3 ( 1 ) + 1 ( − 1 ) + 4 ( 1 )) = 2 1 ( 4 ) = 2 Now to go to the periodogram from the DFT, we can do:
P ( j / n ) = ( 4 / n ) ∣ d ( j / n ) ∣ 2 P ( 0 / 4 ) = ( 4 / 4 ) ∣ 5 ∣ 2 = 25 P ( 1 / 4 ) = ( 4 / 4 ) ∣ 0.5 − 0.5 i ∣ 2 = 0.5 P ( 2 / 4 ) = ( 4 / 4 ) ∣ 2 ∣ 2 = 4 P ( 3 / 4 ) = P ( 1 / 4 ) \begin{aligned}
P(j/n) &= (4/n) |d(j/n)|^2\\
P(0/4) &= (4/4) | 5 | ^2 = 25\\
P(1/4) &= (4/4) | 0.5 - 0.5i|^2 = 0.5\\
P(2/4) &= (4/4) | 2 | ^2 = 4\\
P(3/4) &= P(1/4)\\
\end{aligned} P ( j / n ) P ( 0/4 ) P ( 1/4 ) P ( 2/4 ) P ( 3/4 ) = ( 4/ n ) ∣ d ( j / n ) ∣ 2 = ( 4/4 ) ∣5 ∣ 2 = 25 = ( 4/4 ) ∣0.5 − 0.5 i ∣ 2 = 0.5 = ( 4/4 ) ∣2 ∣ 2 = 4 = P ( 1/4 ) The way to interpret this is that the DFT is a complex number that encodes both amplitude and phase at each frequency.
Periodogram demo ¶ Read Chapter 4.4 for more info on periodogram smoothing.