Saturday 9 January 2016

window functions - Where do we use windowing?


I have been studying about the box window and am unable to understand one thing, do we first sample a signal and then window it resulting in up-scaling or downscaling, or is windowing a practical case of sampling itself which is performed on a continuous time signal?



Answer



Alright, the way to think about the rectangular window (as well as all of the other windows) is that you begin with an infinite sequence of samples and you multiply the samples outside the window with 0 and the samples within the window with something non-zero (and usually, but not always, positive).


So the DFT (of which the FFT is fast method of doing the DFT) does periodically extend the $N$ samples passed to it. But there are a couple of different ways of looking at it. One way to look at it is with just the definitions of the DFT and iDFT:


$$ X[k] = \sum\limits_{n=0}^{N-1} x[n] \ e^{-j 2 \pi nk/N} $$


$$ x[n] = \frac{1}{N}\sum\limits_{k=0}^{N-1} X[k] \ e^{j 2 \pi nk/N} $$



The $x[n]$ that the DFT $X[k]$ is aware of is simply a periodic sequence with period of $N$. both $$ x[n+N]=x[n] $$ and $$ X[k+N]=X[k] $$ are true.


Now the alternative way to think about the DFT is that it is the sampling of the spectrum of the Discrete-Time Fourier Transform (DTFT):


$$ \hat{X}\left( e^{j \omega} \right) = \sum\limits_{n=-\infty}^{+\infty} \hat{x}[n] \ e^{-j \omega n} $$


where $ \hat{x}[n] = \begin{cases} 0, & n < 0 \\ x[n], & \text{for }0 \le n < N \\ 0, & N \le n \end{cases} $


and this is the same as multiplying by a rectangular window.


$$ \hat{x}[n] \ = \ x[n] \ w[n] $$


where $ w[n] = \begin{cases} 0, & n < 0 \\ 1, & \text{for }0 \le n < N \quad \quad \\ 0, & N \le n \end{cases} $ (length-$N$ rectangular window)


But here you cannot tell that you extracted $\hat{x}[n]$ from a periodic $x[n]$ or if those $N$ samples came from an infinitely long and non-repeating stream of samples. Whatever it is, $\hat{x}[n]$ is non-repeating, infinite in length (with all those zeros padded), and you can apply the DTFT to it.


It doesn't have to be the rectangular window, it could be any length-$N$, finite-valued window for $w[n]$ and the math that follows is the same.


Now with that definition of $\hat{x}[n]$ and $\hat{X}\left( e^{j \omega} \right)$, it's not hard to show that



$$ \hat{X}\left( e^{j \omega} \right) \Bigg|_{\omega = 2 \pi \frac{k}{N}} = \hat{X}\left( e^{j 2 \pi k/N} \right) = X[k] $$


Now, what happens in either domain, is that when you uniformly sample the function (say, in this case, the spectrum $\hat{X}\left( e^{j \omega} \right)$) in one domain, it causes in the other domain, the signal ($\hat{x}[n]$) to be repeatedly shifted (by $N$ samples) and overlap-added:


$$ x[n] = \sum\limits_{m=-\infty}^{+\infty} \hat{x}[n+mN] $$


It is here where the discontinuity between $x[N-1]$ and $x[N]$ (which is the same as $x[0]$) becomes a concern, and tapered windowing to reduce or eliminate this discontinuity is perhaps indicated.


No comments:

Post a Comment

readings - Appending 内 to a company name is read ない or うち?

For example, if I say マイクロソフト内のパートナーシップは強いです, is the 内 here read as うち or ない? Answer 「内」 in the form: 「Proper Noun + 内」 is always read 「ない...