The Sliding Window Discrete Fourier Transform Lee F
Total Page:16
File Type:pdf, Size:1020Kb
The Sliding Window Discrete Fourier Transform Lee F. Richardson Department of Statistics and Data Science, Carnegie Mellon University, Pittsburgh, PA The Sliding Window DFT Sliding Window DFT for Local Periodic Signals Leakage The Sliding Window Discrete Fourier Transform (SW- Leakage occurs when local signal frequency is not one DFT) computes a time-frequency representation of a The Sliding Window DFT is a useful tool for analyzing data with local periodic signals (Richardson and Eddy of the Fourier frequencies (or, the number of complete signal, and is useful for analyzing signals with local (2018)). Since SW-DFT coefficients are complex-numbers, we analyze the squared modulus of these coefficients cycles in a length n window is not an integer). In this periodicities. Shortly described, the SW-DFT takes 2 2 2 case, the largest squared modulus coefficients occur at sequential DFTs of a signal multiplied by a rectangu- |ak,p| = Re(ak,p) + Im(ak,p) frequencies closest to the true frequency: lar sliding window function, where the window func- Since the squared modulus SW-DFT coefficients are large when the window is on a periodic part of the signal: Frequency: 2 Frequency: 2.1 Frequency: 2.2 Frequency: 2.3 Frequency: 2.4 20 Freq 2 20 Freq 2 20 Freq 2 20 Freq 2 20 Freq 2 tion is only nonzero for a short duration. Let x = Freq 3 Freq 3 Freq 3 Freq 3 Freq 3 15 15 15 15 15 [x0, x1, . , xN−1] be a length N signal, then for length 10 10 10 10 10 n ≤ N windows, the SW-DFT of x is: 5 5 5 5 5 0 0 0 0 0 0 50 100 150 200 250 0 50 100 150 200 250 0 50 100 150 200 250 0 50 100 150 200 250 0 50 100 150 200 250 1 n−1 X −jk Frequency: 2.5 Frequency: 2.6 Frequency: 2.7 Frequency: 2.8 Frequency: 2.9 ak,p = √ xp−n+1+jω 20 Freq 2 20 Freq 2 20 Freq 2 20 Freq 2 20 Freq 2 n n Freq 3 Freq 3 Freq 3 Freq 3 Freq 3 j=0 15 15 15 15 15 k = 0, 1, . , n − 1 10 10 10 10 10 p = n − 1, n, . , N − 1 (1) 5 5 5 5 5 0 0 0 0 0 0 50 100 150 200 250 0 50 100 150 200 250 0 50 100 150 200 250 0 50 100 150 200 250 0 50 100 150 200 250 i2π 2π 2π where ωn = exp( n ) = cos( n ) + i sin( n ). The SW- Squared Modulus SW-DFT coefficients for frequencies with 2 and DFT results in a n×P = N −n+1 array, where n cor- 3 complete cycles, where true frequency ranges from 2 − 2.9. responds to frequencies and P corresponds to window Ringing position. A useful way to think about the SW-DFT is a multivariate time-series, where each time-series cor- Discontinuous signals lead to a phenomenon called 2πk responds to a Fourier frequency ( n ). ringing. For local signals, ringing occurs when the window is only on part of the local periodic signal, corresponding to states 2 and 4 in the figure below: The Fast Sliding Window DFT 2π·t·16 Left: Length 128 signal x, where xt = 2 cos( 128 ) · I[32,94](t). Right: Squared Modulus coefficients for the SW-DFT of x. Window covers only the signal Computing the SW-DFT by definition (Equation 1) Window covers part of signal Window covers part of signal 2 takes P n operations. We can easily reduce this to STATE 3 O(P n log(n)) by replacing the DFT in each window Modeling a Local Signal Estimating a Local Signal STATE 2 STATE 4 position with a Fast Fourier Transform (FFT). We fur- We use the following model for a local periodic signal: Let x = [x , x , . , x ] be a length N signal. The STATE 1 STATE 5 ther reduce the computational complexity to O(P n) 0 1 N−1 SW-DFT of x is: Signal enters window Signal exits window using the Fast SW-DFT algorithm (Richardson and 2πtF Eddy (2017)). The Fast SW-DFT algorithm uses the yt = A cos( + φ) · IS,S+L−1(t) The canonical “trapezoid” shape of a squared modulus SW-DFT N 1 n−1 coefficient for a local periodic signal. tree data-structure of the Cooley-Tukey FFT to remove b = √ X x ω−jk (2) k,p n p−n+1+j n repeated calculations in overlapping windows. where t = 0,...,N − 1. This model has 5 parameters: j=0 Conclusions We want the least-squares parameter estimates The SW-DFT is a useful tool for local periodic signals. 1 S: Start of local signal. S ∈ {0, 1,...,N − 2}. n−1 N−1 X X 2 This poster shows the linear-time Fast SW-DFT algo- 2 L: Length of local signal. L ∈ {1, 2,...,N − S} arg min (bk,p − ak,p) (3) S,L,A,F,φ k=0 p=n−1 rithm, a model for local periodic signals, a trick for es- 3 A: Amplitude. A ∈ [0, ∞] timating parameters of the model, and the “important- 4 F : Complete cycles in a length N signal. F ∈ [0, ∞] Using the following trigonometric identity: for-data-analysis” concepts: Leakage and Ringing. 5 φ: Phase, φ ∈ [0, 2π] cos(x + y) = cos(x) cos(y) + sin(x) sin(y) References The SW-DFT of our model for local signals is: We can linearize the optimization over A and φ: Richardson, L. F. and Eddy, W. F. (2017). An algo- Figure: The Fast SW-DFT algorithm for two adjacent windows. n−1 1 X 2π(pˆ + j)F −jk Window one shows the intermediate FFT calculations for ak,p = √ A cos( + φ) · I[S,S+L−1](pˆ + j)ω rithm for the 2d radix-2 sliding window fourier trans- n N n n−1 N−1 [x , . , x ], and window two shows the same calculations for j=0 X X 2 0 7 arg min(arg min (bk,p − β1C1,k,p − β2C2,k,p) ) form. arXiv preprint arXiv:1707.08213. [x1, . , x8]. The solid arrows in window two indicate calculations where pˆ = p − n + 1. This is easily extended to R S,L,F A,φ k=0 p=n−1 Richardson, L. F. and Eddy, W. F. (2018). The sliding already made in window one, and the dashed arrows are new window discrete fourier transform for time series. In calculations. The new calculations in window two are exactly the local signals, using the linearity property of the Fourier Where C and C are complex-valued vectors (see 1,k,p 2,k,p Preparation. size of a binary tree, which grows linearly with window size. transform. Richardson and Eddy (2018) for more details)..